Java Swing Input

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,273
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on May 29, 2011

How to use Java Swing and get a input!

Code:
import javax.swing.*;
public class Input
{
public static void main(String []args)
{

String in = JOptionPane.showInputDialog(null,"What Is Your Name?","Hello",0);
JOptionPane.showMessageDialog(null,in + " Is A Dumb Name","Hello",0);

while(in.equalsIgnoreCase("John")){
JOptionPane.showMessageDialog(null,"Im Just Kidding","JK",0);
}

}
}

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (1)

Sign In or Sign Up now to post a comment!
  • I'm pretty sure you should invoke all swing-related statements on the AWT dispatch thread. Thus: JOptionPane.showMessageDialog(­"What is your name"), should be enclosed in SwingUtilities.invokeLater(new Runnable(){

    public void run() { // put it here! }});

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more