Home Answers Viewqa Java-Beginners Unable looping using JOptionPane

 
 


Alex
Unable looping using JOptionPane
1 Answer(s)      3 years and 4 months 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));

}

}
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 Pages:
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
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
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
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
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
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   sum of the series s=1+2/1*2
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
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
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 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      
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
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
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
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 install Subversion plugins in MyEclipse
Unable to install Subversion plugins in MyEclipse  Thanks for your reply Deepak. I am using MyEclipse Blue Edition 8.6 M1. I tried adding Subversion plugins and got error. This is the path i followed: Help --> MyEclipse
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
unable to see the output of applet. - Applet
unable to see the output of applet.  Sir, I was going through the following tutorial http://www.roseindia.net/java/example/java/applet.... u just copy that java source code and compile that using javac then you
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
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 structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
Unable to find Software Updates in Help menu in MyEclipse
Unable to find Software Updates in Help menu in MyEclipse  Hi, I am using MyEclipse for my project. I have to use SVN repository for checking the code and need to install Subclipse plugins to MyEclipse. But I am not getting
Unable to call .jrxml file from jsp
Unable to call .jrxml file from jsp  Hi, I am doing web application in jsp. To create report I have used ireport and interated with neatbeans using... then it unable to access it.Error also not showing. I will show my code and its output
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
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
very urgent : Iam unable to code this program plz help me - RMI
very urgent : Iam unable to code this program plz help me  Write a Multi-user chat server and client.  Hi friend, Chat server... side). This application is using for chatting in LAN. To start chatting you
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
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
unable to find resource 'VM_global_library.vm' - Java Server Faces Questions
unable to find resource 'VM_global_library.vm'  pls help me, I am... 2008 [debug] AvalonLogSystem initialized using logfile 'velocity.log' Tue Aug 12...:03:54 CAT 2008 [info] Using logger class
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
JOptionPane - Java Beginners
and output should be via JOptionPane dialogue boxes. Examples are shown below
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct, that enables the repeated execution... with Example The Tutorial illustrate an example from 'Mysql Looping'. To understand
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct,that enables the repeated... with Example The Tutorial illustrate an example from 'Mysql Looping'.To understand
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
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
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 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
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. 
javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection - JSP-Servlet
javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection  Hi.i am beginner. using eclipse. i am sure my deployment... ServletException("Initialization failed, Unable to get DB connection
Looping Statements in java 7
Looping Statements in java 7 In this section, we will discuss about Looping Statements in java 7. This is one type of control flow statement. Looping... of statements repeatedly. Following are three types of Looping statements
Unable to execute JSP page
Unable to execute JSP page  I have written one jsp file. It contains html tags and jsp directives. I have saved the file with the extension .jsp. The tomcat server is already running onto my machine. I have saved the jsp file
Unable to use JMXMP with Knopflerfish?
Unable to use JMXMP with Knopflerfish?  I have a bundle which runs properly with Eclipse, then I generate the jar file and try to use it with Knopflerfish, then I get the following exception java.net.MalformedURLException
Unable to compile Servlet
Unable to compile Servlet  First I installed the tomcat server in C:\apache-tomcat-6.0.14 directory. Then I created a system variable CATALINA_HOME with the value C:\apache-tomcat-6.0.14. Then I created another system variable

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.