Unable looping using JOptionPane

Ads

 
 

Share on Google+Share on Google+

Alex
Unable looping using JOptionPane
1 Answer(s)      7 years ago
Posted in : Java Beginners
import javax.swing.*;

public class Shop{

public static void main(String [] args){

Shop shop = new Shop();

String mainMenu= "(MAIN SCREEN )";
mainMenu+= "\n1) Computer Menu";
mainMenu+= "\n2) Storage Menu";
mainMenu+= "\n3) Transaction Menu";
mainMenu+= "\n4) Exit";
mainMenu+= "\nPlease select your choice:";

int choice = Integer.parseInt(JOptionPane.showInputDialog(mainMenu));
while (choice!=4);
switch(choice){
case 1:
shop.computerMenu();
break;
case 2:
break;
case 3:
break;
case 4:
break;
}

}
public void computerMenu(){
String computerMenu= "Computer Menu";
computerMenu+= "\n1) Buy Computer";
computerMenu+= "\n2) Sell Computer";
computerMenu+= "\n3) View Computer";
computerMenu+= "\n4) Back To Main Menu";
computerMenu+= "\nPlease select your choice:";

int choice1 = Integer.parseInt(JOptionPane.showInputDialog(computerMenu));

}

}
Ads
View Answers

February 1, 2010 at 5:32 PM


Hi Friend,

Try the following code:

import javax.swing.*;

public class Shop{

public static void main(String [] args){

Shop shop = new Shop();

String mainMenu= "(MAIN SCREEN )";
mainMenu+= "\n1) Computer Menu";
mainMenu+= "\n2) Storage Menu";
mainMenu+= "\n3) Transaction Menu";
mainMenu+= "\n4) Exit";
mainMenu+= "\nPlease select your choice:";

int choice = Integer.parseInt(JOptionPane.showInputDialog(mainMenu));
switch(choice){
case 1:
String computerMenu= "Computer Menu";
computerMenu+= "\n1) Buy Computer";
computerMenu+= "\n2) Sell Computer";
computerMenu+= "\n3) View Computer";
computerMenu+= "\n4) Back To Main Menu";
computerMenu+= "\nPlease select your choice:";
int choice1 = Integer.parseInt(JOptionPane.showInputDialog(computerMenu));
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
Unable looping using JOptionPane - Java Beginners
Unable looping using JOptionPane  import javax.swing.*; public class Shop{ public static void main(String [] args){ Shop shop = new Shop(); String mainMenu= "(MAIN SCREEN )"; mainMenu+= "\n1) Computer Menu
Selection Using JoptionPane
Selection Using JoptionPane  Help, can someone provide me the code using JOptionPane for the following:- Part A 1) Prompt user to make 3 selection i.e 1)Orchid $4.00 2)Rose $2.50 3)Daisy $5.00 or 0 to Quit 2) if user
Advertisements
Get and Display using JOptionPane
from student, name and age, by using JOptionPane. Then display it. Really...Get and Display using JOptionPane  Hello everyone, I have been asked by my lecturer to do a simple program. But, I don't have the idea how to start
looping ..
looping ..  can i get coding for get the following output: (using looping) 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
looping
looping   sum of the series s=1+2/1*2
Unable to send mail using php script
Unable to send mail using php script  Hello i am trying to send mail using mail function.But the message is never sent. I have installed a free smtp server which i run in background before executing the code.and my php.ini file
Unable to upload a file to mysql database using struts1
Unable to upload a file to mysql database using struts1  Hi, Below are my classes 1.upload.jsp <%@ taglib uri="/tags/struts-html" prefix="html" %> <html:html> <body> <html:form action="upload" enctype
Unable to bind to a hashmap from jsp using spring tags - Spring
Unable to bind to a hashmap from jsp using spring tags  Hi, I am unable to bind a hashmap from my jsp page. Here is what i want to do: I have... = hmlist; } } My JSP Page is like this: /* * Looping through
joptionpane validation
joptionpane validation  import javax.swing.*; import java.util.regex.*; public class joptionpane { public static void main(String[] args... help me!i need to validate the user input on the joptionpane,and if the user
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver  Hi, i have a servlet program..to verify the login and redirect to correct...(request,response); } } .i am unable to redirect..here is the code..pls
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
shape looping
shape looping  can some1 help me?i have to make a shape using "*" by looping...and i dun know how...please and thank you * **   java diamond shape: public class Diamond{ public static void main(String[] args){ int
looping with strings
looping with strings  how to print this w we wel welc welco with loop?   import java.util.*; class StringExample3 { public static void main(String[] args) { Scanner input=new Scanner(System.in
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt
looping structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
looping through a list of methods
looping through a list of methods  I have a number of methods that do the almost same thing: public void setColorRed (int colorvalue); public... the loop using the same colorvalue? for Thanks in advance
looping programm of sum
looping programm of sum  s=1+2/12+1+2+3/12*3+1+2+3+..... n
Flex Looping
.style1 { border-style: solid; border-width: 1px; background-color: #FFFFCC; } Executing a set of statements repeatedly is performed through looping. For this purpose, Flex provides some looping mechanism like: 1
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane validation. I have joptionpane inputdialog textbox.I need to enter the string values only in the textbox for validation. Please send the sample code immediately. Its very urgent
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help  import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException
Set Color in JOptionPane
Set Color in JOptionPane       In this section, you will learn how to set color in JOptionPane. Now to do this, we have used UIManager class which is responsible for look and feel. Using
Set text color in JoptionPane
Set text color in JoptionPane In this section, you will learn how to set text color in JOptionPane. Now to do this, we have used UIManager class which is responsible for look and feel. Using following key value pair, we have set the text
Ask about looping in database
Ask about looping in database  Good afternoon, I want to ask... that how to read looping in field rights(if A1=false and A2 = True), use from java. i want to call rights looping with code program from java. i read from datatase
joptionpane - Java Beginners
joptionpane   I need joptionpane showinputdialog textbox integer validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane showinputdialog textbox string validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
Array in JOptionPane - Java Beginners
Array in JOptionPane  Hello, I'm having trouble with printing an array in a JOptionPane. I am supposed to make a 2 dimensional int array called BlasTable. I'm supposed to use a method to print the array in a JOptionPane
joptionpane - Java Beginners
joptionpane  Hi, I need to change the JOptionpane foreground text color only. Please send the sample code. JOptionPane.showMessageDialog(createqmbutton, "Succesfully Create the Queue Manager", "Create Queue
farbonicci in looping - Spring
farbonicci in looping  how to make a program use farbonicci in looping?  import java.io.*; public class FibonciiExample{ public static void main(String[] args) throws Exception{ System.out.println("Fibonccii
Set delay time in JOptionPane
the message should be displayed using JOptionpane. For this, first of all we prompt the user to enter time in seconds and the message to display. After that using... Set delay time in JOptionPane      
joptionpane - Java Beginners
joptionpane  Hi, I need to hide the joptionpane message dialogs. import javax.swing.*; import java.util.regex.*; public class ValidateJOptionPane { public static void main(String[]args){ String input

Ads

 
Advertisement null

Ads