Results 1 to 2 of 2
- 12-10-2011, 07:08 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
Keeping a JOptionPane window open after selection.
Hello,
First off let me just say that I am a complete beginner with Java; so if my question seems stupid it's probably because I don't know enough to ask the right question. I'll start by explaining what I'm trying to do and then ask my question.
Goal:
Create a small program that tells the user the birthday of the name typed in. I would like to be able to type a name get their birthday and then be taken back to the "name prompt" again.
Problem:
After I type my first name into the dialog box the program tells me the birthday and then automatically shuts down.
Question:
How can I get it to go back to the start after it displays the birthday instead of shutting down?
Current Code:
import javax.swing.JOptionPane;
public class birthday {
public static void main(String[] args) {
String response;
response=JOptionPane.showInputDialog("Who's Birthday would you like to know?");
if (response.equals("Jessica"))
JOptionPane.showMessageDialog(null, "December 17, 1985");
else
if (response.equals("Jessica Hildebrandt"))
JOptionPane.showMessageDialog(null, "December 17, 1985");
else
if (response.equals("Nate"))
JOptionPane.showMessageDialog(null, "December 13, 1980");
else
if (response.equals("Nathan"))
JOptionPane.showMessageDialog(null, "December 13, 1985");
else
if (response.equals("Nathan Hildebrandt"))
JOptionPane.showMessageDialog(null, "December 13, 1985");
else
if (response.equals("Nate the great"))
JOptionPane.showMessageDialog(null, "December 13, 1985");
else
if (response.equals("Kaylee"))
JOptionPane.showMessageDialog(null, "July 28, 2006");
else
if (response.equals("Kaylee Hildebrandt"))
JOptionPane.showMessageDialog(null, "July 28, 2006");
else
if (response.equals("Stugry"))
JOptionPane.showMessageDialog(null, "July 28, 2006");
else
if (response.equals("Bethany"))
JOptionPane.showMessageDialog(null, "April 18, 1985");
else
if (response.equals("Bethany Hildebrandt"))
JOptionPane.showMessageDialog(null, "April 18, 1985");
else
if (response.equals("Beth"))
JOptionPane.showMessageDialog(null, "April 18, 1985");
else
if (response.equals("Mom"))
JOptionPane.showMessageDialog(null, "April 14, ????");
else
if (response.equals("Shirley Hildebrandt"))
JOptionPane.showMessageDialog(null, "April 14, ????");
else
if (response.equals("Shirley"))
JOptionPane.showMessageDialog(null, "April 14, ????");
else
if (response.equals("Dad"))
JOptionPane.showMessageDialog(null, "October 4, ?????");
else
if (response.equals("Grant Hildebrandt"))
JOptionPane.showMessageDialog(null, "October 4, ????");
else
if (response.equals("Grant"))
JOptionPane.showMessageDialog(null, "October 4, ????");
}
}Last edited by Joshuak; 12-10-2011 at 07:21 AM.
- 12-10-2011, 09:11 AM #2
Member
- Join Date
- Oct 2011
- Posts
- 79
- Rep Power
- 0
Similar Threads
-
Program Using JOptionPane to say Hello to the user in a pop-up window
By Interista in forum New To JavaReplies: 2Last Post: 10-20-2011, 03:43 PM -
how to disable the parent window when child window is open
By ayushi in forum Java ServletReplies: 1Last Post: 07-25-2011, 11:24 AM -
how to use window.open(...) in a jsp to call a servlet and open jsp in a new window.
By ajincoep in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 02-07-2011, 09:43 AM -
Keeping one window above another
By porchrat in forum AWT / SwingReplies: 3Last Post: 01-27-2011, 09:11 AM -
How do i show all the values in one window(JOptionPane)??
By Antonioj1015 in forum Advanced JavaReplies: 1Last Post: 11-25-2009, 05:17 PM
Bookmarks