Unable looping using JOptionPane

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";
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));

}

}
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









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
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
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
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
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
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 structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
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
looping
ModuleNotFoundError: No module named 'looping'
ModuleNotFoundError: No module named 'looping'  Hi, My Python... 'looping' How to remove the ModuleNotFoundError: No module named 'looping... to install padas library. You can install looping python with following command
ModuleNotFoundError: No module named 'looping'
ModuleNotFoundError: No module named 'looping'  Hi, My Python... 'looping' How to remove the ModuleNotFoundError: No module named 'looping... to install padas library. You can install looping python with following command
ModuleNotFoundError: No module named 'looping'
ModuleNotFoundError: No module named 'looping'  Hi, My Python... 'looping' How to remove the ModuleNotFoundError: No module named 'looping... to install padas library. You can install looping python with following command
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
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
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
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
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
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
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
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
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
and output should be via JOptionPane dialogue boxes. Examples are shown below
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      
ModuleNotFoundError: No module named 'anaharid-looping'
ModuleNotFoundError: No module named 'anaharid-looping'  Hi, My... named 'anaharid-looping' How to remove the ModuleNotFoundError: No module named 'anaharid-looping' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'looping_list'
ModuleNotFoundError: No module named 'looping_list'  Hi, My Python... 'looping_list' How to remove the ModuleNotFoundError: No module named 'looping_list' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'looping_list'
ModuleNotFoundError: No module named 'looping_list'  Hi, My Python... 'looping_list' How to remove the ModuleNotFoundError: No module named 'looping_list' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'looping_list'
ModuleNotFoundError: No module named 'looping_list'  Hi, My Python... 'looping_list' How to remove the ModuleNotFoundError: No module named 'looping_list' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'anaharid-looping'
ModuleNotFoundError: No module named 'anaharid-looping'  Hi, My... named 'anaharid-looping' How to remove the ModuleNotFoundError: No module named 'anaharid-looping' error? Thanks   Hi, In your
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
unable to execute the examples
unable to execute the examples  unable to execute the examples given for struts,ejb,or spring tutorials.Please help I am a beginner
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct,that enables the repeated... 'Mysql Looping'.To understand this example we create a procedure 'ABC
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct, that enables the repeated execution... with ExampleADS_TO_REPLACE_1 The Tutorial illustrate an example from 'Mysql Looping
JOptionPane Validation
JOptionPane Validation JOptionPane allow you to create dialog boxes easily... look complex. Here we are going to validate the textfield of JoptionPane dialog. JOptionPane String Validation We have used regular expression that 
Unable to Create DSN for
Unable to Create DSN for   I have installed Oracle 11g R2 and JDK7... Driver. I'm unable to crate DNS for "Microsoft ODBC for Oracle", It gives eror... using text editor (not eclipse etc).... If possible, please kindly provide
unable to open the service tomcat5
unable to open the service tomcat5  While trying to run tomcat server getting "unable to open the service tomcat5" error after installed tomcat
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName
Example of Looping in Python
Example of Looping in Python - Learn looping in Python Let's learn looping in Python with the example code. What is Loop? In computer programming... once counter increased more than 100. ADS_TO_REPLACE_1 Looping in programming
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code. try { Driver d=(Driver)Class.forName
Java ComboBox in JOptionPane
Java ComboBox in JOptionPane In this section, you will learn how to create combo box in JOptionPane dialog box. We have created a button to perform an action.On clicking the button, you will get the dialog box with combo box in it. 

Ads