Results 1 to 3 of 3
  1. #1
    blueyan is offline Member
    Join Date
    Sep 2008
    Posts
    14
    Rep Power
    0

    Default [SOLVED] JOptionPaneMessage dialog question

    i am doing a program about vending machine. i want to do in the JOptionPane way instead of scanner scan (println)...


    Java Code:
     while(option!=5){      
                if(option==1){
                    count1++;
                System.out.println("Here is your gum\n");}
                else if(option==2){
                    count2++;
                System.out.println("Here is your chocolate\n");}
                else if(option==3){
                    count3++;
                System.out.println("Here is your popcorn \n");}
                else if(option==4){
                    count4++;
                System.out.println("Here is your juice \n");}
                    
                            
                System.out.println("[1] Get gum\n[2] Get chocolate\n[3] Get popcorn\n[4] Get juice\n" +
                        "[5] Display total sold\noption : ");
                       option= scan.nextInt();
                }
    so if user enter option " 1 " , then count1 ++...after that user terminate the program ( by enter 5 ) , the println will print out the item sold , by checking each count condition( count1 , count 2...)

    in this case , " 1 items of gum were sold " will print out

    Java Code:
      if(count1>0){ //results
                System.out.println( count1+" items of gum were sold"); }
            if (count2>0){
                System.out.println(count2+" items of chocolate were sold");}
            if (count3>0){
                System.out.println( count3+" items of popcorn were sold");}
            if (count4>0){
                System.out.printf(count4+" items of juice were sold");}
    so my question is , if there any method that i can use JOptionPaneMessageDialog to show these result , i mean only the sold items display in ONE JOptionPaneMessageDialog

    i will appreciate if someone can reply me:)
    Last edited by blueyan; 09-28-2008 at 06:57 AM.

  2. #2
    blueyan is offline Member
    Join Date
    Sep 2008
    Posts
    14
    Rep Power
    0

    Default

    i got the solution already , post closed

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Nice to see that you have figure out the problem yourself. When you do it next time, I mean after solve your problem, mark it as solved using Thread Tools.

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. Dialog
    By JavaLerner in forum AWT / Swing
    Replies: 27
    Last Post: 07-07-2008, 11:29 AM
  3. Example of SWT Dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:01 PM
  4. Dialog Box
    By uncopywritable in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •