Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Modal dialog with OKcancel and a text field

import javax.swing.JFrame; import javax.swing.JOptionPane; public class Main {   public static void main(String[] argv) throws Exception {     JFrame frame = new JFrame();     String message = "message";     String text = JOptionPane.showInputDialog(frame, message);     if (text == null) {       // User clicked cancel     }   } }