Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Input Pop-Ups

The return value is either what the user typed in a text field (a String) or what the user picked from a list of options (an Object). import javax.swing.JFrame; import javax.swing.JOptionPane; public class InputPopUps {   public static void main(String[] a) {     JFrame frame = new JFrame();     Object result = JOptionPane.showInputDialog(frame, "Enter printer name:");     System.out.println(result);   } }