Trying to print a list using JOptionPane
811746Nov 9 2010 — edited Nov 9 2010I am very new to Java and programming, so please forgive me if this should be apparent. I wrote a program for school which was for ordering pizzas. I wrote it as a console program and after much frustration it finally worked. Now I am trying to change it to a GUI program using JOptionPane. I was hoping that since I already had the logic written and working, I could focus on the GUI aspect. I was wrong. I want to print a list of enums on a JOptionPane and cannot figure out how to do it My code in the console program was:
System.out.println("The available crust styles are: ");
{
for(Pizza.Style style : Pizza.Style.values())
{
System.out.println(style+" ");
}
}
So how can I iterate through the for loop to list all of the styles in the JOptionPane? Do I need to turn it into a method with a return and then cal the method like
JOptionPane.showMessageDialog(null, crustMethod()); ??