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);
}
}
}
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! }});
scarfulify 4 months ago