The Artima Developer Community
Sponsored Link

Java Answers Forum
ShowInputDialog problems!! need help

1 reply on 1 page. Most recent reply: Apr 28, 2004 9:41 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Cubez

Posts: 1
Nickname: cubez
Registered: Apr, 2004

ShowInputDialog problems!! need help Posted: Apr 27, 2004 10:57 AM
Reply to this message Reply
Advertisement
i'm new to Java and i need your help.

Q1:

I'm developing a game and i want the application to ask the user to input a name at the begining

  public class GameWindow {
    static String nameStr; }
 
  public GameWindow{
    nameStr = JOptionPane.showInputDialog(null, "Enter  Name", "Please enter a name:");
    playerArray[0] = new Player(nameStr);
  }


As you can see, if name is entered and ok is pressed then it saves to the player array. I also want the application to exit if cancel is pressed, but i don't know how to do that.


Q2:

In the same application I have a menu bar and I want it to appear before the user is asked to enter a name. Unofrtunately java is not as sequential as pascal. It doesn't allow me to display the menubar before the input dialog even if i put the menubar code before the showInputDialog. So how can I solve this problem?

Thanks alot dudes. I appreciate it.


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: ShowInputDialog problems!! need help Posted: Apr 28, 2004 9:41 AM
Reply to this message Reply
If you press cancel, the return string will be null.

Flat View: This topic has 1 reply on 1 page
Topic: new user's error Previous Topic   Next Topic Topic: PB in db access, URGENT!!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use