Trying to print a list using JOptionPane

I 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()); ??

OP said:
... 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 wouldn't use JOptionPane. You need JFrame and maybe, but I doubt it, a JDialog. OP, the GUI is more than likely to be nothing more than a form that allows users to set certain properties or fields in a Java class. For example let's say we have this class.
public class Point
  public int x;
  public int y;
}Then a GUI for this would be something like a JPanel with two (2) JLabels and two (2) JTextFields. Maybe something like so...
import java.awt.*;
import javax.swing.*;
public class PointGUI extends JPanel
  public JLabel xLabel = new JLabel("Coordinate X:");
  public JLabel yLabel = new JLabel("Coordinate Y:");
  public JTextField xField = new JTextField(4);
  public JTextField yField = new JTextField(4);
  public PointGUI(){
    setLayout(new GridLayout(2, 2));
    add(xLabel);
    add(xField);
    add(yLabel);
    add(yField);
}Then to run the program...
import javax.swing.*;
public class Test
  public static void main(String[] args){
    SwingUtitlities.invokeLater(new Runnable(){
      public void run(){
        PointGUI gui = new PointGUI();
        JFrame f = new JFrame("PointGUI");
        f.getContentPane().add(gui, "Center");
        f.pack();
        f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
        f.setVisible(true);
}... actually all the program does is display the GUI. But, can you see that the GUI's JLabels and JTextFields describe all the public properties of the Point class? Can you see that the entire GUI can be placed anywhere in a JFrame, or maybe even in a JDialog? From this point on, you can add other functions and features to your classes, GUI's and the main apps that run them.
A hint on your project, you may need to write a Pizza class that decribes all the things a single pizza can be - then come up with a GUI for that and an app that runs it.

Similar Messages

  • I'm trying to create a list using CustomSchemalXml property in ListCreationInformation object in CSOM. But, the code throws an error "Invalid List Schema".

    I'm trying to create a list using CustomSchemalXml  property in ListCreationInformation object in CSOM. But, the code throws an error "Invalid List Schema". Any pointers on how to set the CustomSchemalXml property?
    Sri

    Hi Lakshmanan,
    Thanks for your reply.
    I checked this post and there was no solution to the problem there. I undersand we cannot create a list based on custom template in CSOM, but what I'm looking for is how of form xml and set it to CustomSchemalXml
     property, so that everytime when I want to create a list with similar content types and stuff, I can just set the
    CustomSchemalXml  property. 
    Sri

  • Trying to print e-mails using iCloud but can not add my printer Epson Stylus Photo PX810FW Why not?r

    Trying to print e-mails using iCloud but can not add my printer Epson Stylus Photo PX810FW
    Why not?

    Trying to print e-mails using iCloud but can not add my printer Epson Stylus Photo PX810FW
    Why not?

  • Trying to print ABAP List in Unix

    I am new to SAP and I am trying to print using unix as my host spooler.  I am printing to a Xerox machine connected to a print server.  I am just trying to print the test ABAP list you get when you go into SPAD and select Utilities/ouput devices then select ABAP List.  When I print this I get nothing but ABCD and a bunch of numbers.  I am trying to figure if the ABAP list is supposed to be that way or if something is wrong with my driver.

    Hello Rodney,
    What device type did you specify in the SPAD Output Device definition?  You need to make sure you select a device type which is compatible with the printer.  If the printer supports postscript printer language, then you need to select the 'Post2' or 'postscpt' device types.  If the printer support PCL, then test with 'hplj4' device type.  Most likely the currently selected device type is not compatible with the printer and therefore creates a print file which the printer cannot interpret.
    Regards,
    Nathan

  • Trying to print to video using in and out

    I am trying to print to video (Mini DV) using in and out points. It works fine when I just play through the camera and record and it will print to video when I start at the beginning, but when I place in and out points and I have set the media to print "In to Out", but it just records the black leader then stops.

    For exporting, IN and OUT points must be set in the +timeline of the sequence+ you want to export: make sure the timeline is selected, but NO clip in the timeline is selected before setting the points (use ****-cmd-A to deselect all clips).
    If they are properly set you'll see an highlighted area in the timeline between the IN and the OUT points.
    Piero

  • I'm trying to print envelopes by using Pages merge.  It continues to read it as a 8.5X11 sheet even though I have set the page size to 6.5X4.75

    I've merged names and addresses to be printed in Pages.  The page size is set to 6.5 x 4.75 but the printer keeps trying to print as if it is an 8.5 x 11 sheet. Any ideas where I'm missing a setting?  I've been merging things for 25 years and I've never had this problem.

    Hi fruhulda!
    Thank you so much!  I called the printer company and finally got the problem solved.  This printer must print with the long side oriented as the pass through.  The envelope I was using had been oriented to have the short side pass through.  It doesn't really seem logic that the printer cannot print the sizes entered but when I changed the orientation in Page Set Up it worked. 
    Had I check this would have certainly helped.
    Melmom

  • Adobe PDF printer not listed using Acro8Pro

    Using AcroPro8 and Win8 I don't have a the Adobe PDF printer available from my list of printers. When I install AcroPro7 it returns. ANy ideas?
    Thanks,
    Mart

    Sorry for the misunderstanding. Perhaps I could put it more clearly: "Since you have upgraded Windows, it is time to also upgrade Acrobat". The only version currently sold is XI (11).
    I observe from this page http://www.adobe.com/uk/products/acrobatpro/buying-guide-upgrade-pricing.html that upgrade pricing for Acrobat 8 is only available until May 31, 2013. After that, a full price purchase will be needed.

  • Safari shuts down when trying to print, I'm using 10.6.8

    Safari crashes when I try to print, using 10.6.8.

    Troubleshoot Safari extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.
    If it's not an extension issue, restart your Mac and printer then try again.
    If that doesn't help, reset the print system >>  Mac OS X: How to reset the printing system

  • Trying to print from iPad2 using Fingerprint2

    Hi
    I have an iPad2 and my husband has a MacBook Pro. I've installed Fingerprint2 on the MacBook to enable me to print from the iPad to our HPCP1515n printer, which is not an Airprint printer.
    Installed Fingerprint fine but whenever I ask to print, I get a 'printer offline' message...Help!!
    Also, MacBook is awake and printer plugged in...
    Any help gratefully received!! 
    Thanks, Helen.

    have you asked in the hp forum where more owners and maybe even hp staff would be reading your post?

  • How can I print a list of the songs I have in my iTunes library?

    I have iTunes 6.0.2 installed in my iMac. There are now about 300 songs in my iTunes library. I've tried to print a list of these songs, but only one page will print. How can I get my printer to print as many pages as it takes to print all of the song titles?
    iMac DV (Special Edition) Mac OS X (10.3.9)

    "Page setup" not do anything for you? Are you
    selecting all the songs in your library before you
    try to print?
    I never knew what "Page Setup" was for nor have I ever used it. Nevertheless, it did the trick, and I was able to print all six pages. I'll have to confess, though, that I still don't understand what "Page setup" is for, even though it helped me this time. I don't like to print many pages but I have, sometimes even over 100 at a time, and I never had to use "Page setup". I just said to print ALL, and that was all that was necessary. All I can say about "Page setup" is that it should be tried if the usual methods don't work. Thanks for bringing it to my attention, and thanks for your help.
    iMac DV (Special Edition) Mac OS X (10.3.9)

  • Is it possible to print a list of files bet specific dates in PSE7?

    I am trying to print a list of all the photos inc the shot date so I can check I have scrapbook layouts for all the photos in 2009.  I can organise the photos in date order using the thumbnail view but I can't sit there with my albums and check the layouts are in the correct order so would like a printout.  Can it be done in PSE7?

    You might want to look for an add-on for this.
    Although Firefox has a feature to export your bookmarks to an HTML file which you could view in Firefox and copy from or print as with any other web page, it only shows the descriptive text and not the website address, so I suspect that isn't going to be very useful.
    If you want to try to work with the built-in features, I suggest:
    (1) Export your bookmarks to an HTML file; save it in a convenient location such as your Desktop or My Documents. This article has the steps: [[Export Firefox bookmarks to an HTML file to back up or transfer bookmarks]]
    (2) Open that HTML file in Firefox as a web page. You can double-click it (if it has a .htm or .html extension), or drag and drop the file onto an open tab, or use the menu: tap the Alt key > File menu > Open File.
    (3) Locate the portion of the file you want to print, and select it. ''Do not print from Firefox because the selection printing generates needless blank pages.'' Instead, copy the selected bookmarks and paste into a blank word processing document or new email message to yourself. Then you can print from there.

  • How do I view my subfolders so I can print a list of my directory (main folders and internal subfolders) without clicking the triangle to expand each main folder?

    In VIEWING (to print) my iTunes music (in finder), how can i view subfolders without clicking on the  triangle of each main folder?
    I am trying to print a list of all my music. For example, main folder is BEATLES.  Subfolders are Magical Mystery Tour, Yellow Submarine, Abbey Road, etc...
    and I want to view and print all the subfolders. This is a recovery project after my hard drive failed. I know this is truly a "finder" question and will double post there.
    Thanks.
    Amy

    Try PrintWindow:
    http://www.macupdate.com/app/mac/6465/print-window
    Regards.

  • Warning Message when trying to print form

    Hello,
    We made some changes to a SAPScript and it's print program.  Everything was looking good untill the client tested it in the production box.  When trying to print the receipt using FB12 (to choose correspondence type), F.61 (to issue the spool request) and SP01 (To display the output) the following warnings where displayed in F.61 and the spool request was never issued.
    Can anyone help?? Thanks in advance.
    1. Message ID FB, Message #219 - Doc.type DZ correspondence lang.  doc.type name lang. E
    2. Message ID FB, Message #826 - Output of correspondence ZLMR1 1500 1400000001 2010 *******  20100921 101023 for acct type/acct D ##########
    PD. I've replaced username with * and accnt ID with # signs.

    To be more specific (for future users who will meet this problem);
    Both messages, FB219 and subsequently FB826 are caused by the fact that the description of document type DZ is not maintained in language 'E'. If this desciption is maintained, both messages will vanish.
    Regards,
    Arthur

  • Error printing pick list from IW32

    Hi all,
    When trying to print pick list from transaction IW32, I get this error message:
    Express document "Update was terminated" received from author ...
    When I checked out this error message in SM13, I found this:
    Transaction code: IW32
    Module name (function): PM_ORDER_PRINT_CONTROL
    Status: Update was terminated
    Raise exception: KEY_NOT_FULLY_SPECIFIED (Complete key not entered)
    The shop paper (pick list) is customer defined (Z*) under application area O (Maintenance orders). This shop paper is set up to print to a certain printer, P1, and printing other PLM documents on this output device works fine.
    Does anyone have an idea what can be causing this error?
    All helpful answers will be rewarded.
    Best regards,
    MV

    Hi,
    I have tried to print the pick list several times, in development, test, and production systems. It fails with the same error each time.
    Do you have any ideas why this error occurs, is there any special IMG activity or PLM configuration that I could check to see if some printer settings are wrong?
    Regards,
    MV

  • TRYING TO PRINT ROLODEX CARDS FROM ADDRESS BOOK

    HELP PLEASE,
    I AM TRYING TO PRINT A LIST FORM ON AVERY 5386 ROLODEX CARDS AND I SIMPLY CAN NOT CONFIGURE THE SETTING TO WORK. I CAN GE THE MAILING LABELS PRINTED BUT NOT ALL THE LIST INFO I NEED. ANY IDEAS.

    I worked on this some more and figured out how to get my files into Word and hence onto the Rolodex cards:
    *under Preferences in Address Book choose Vcard, change to 2.1 and keep Western text
    *export chosen cards to desktop from File dropdown (remember to return your Preferences Vcard setting to 3.0)
    *Open Word
    *choose open document and import Vcard file, you get a long list which you will then have to modify (I put returns for the Begin Vcard text to seperate cards), choose the lines you want printed, format text, size, etc
    *following rolodex printer card instructions you can merge your formated data and print!
    Yay, finally. Why doesn't Apple allow this simple type of programability, even labels have been a chore for me.

Maybe you are looking for

  • Laggy wireless trackpad when using Vuze

    I have my macbook pro hooked up with an external monitor, so that I have a dual screen set up. When in this set-up, I use a bluetooth keyboard and a magic trackpad (both Apple) Today, my magic trackpad started to lag pretty bad, but the trackpad on t

  • Getting an error when running Preflight to embed fonts in Acrobat Pro version 9

    I am running Acrobat Pro version 9.4.5 and when I am running a pre-flight for embedding fonts in my document I am getting an error message as follow: " An unexpected error has occurred during the Fixup process ". This is occuring at the font processi

  • I have to have two apple TV to play different playlists using the same AV Receiver dual zone?

    Hi  folks. I have a AV receiver dual zone and I'd like to play different playlists from my computer in each zone. To do that i have to have two Apple TV connected in this Receiver? Thank you in advance. cntg

  • Dock and iPod failure link?

    I have had around 4 iPods (all 20GB, 4G, No Color) in the past year and a half. They usually work well for about 3 months out of the 4 that I have them, then around the 3.5 month mark I start getting Folder+! errors and the sad iPods, so I send them

  • Checking for cycles

    I would think that this is a pretty straightforward task however I'm running into some difficulties. Basically I'm given a bunch of "processes" and which can be exectuted in parallel provided they aren't dependent on another processes finishing first