Modal dialog with OK/cancel and a text field : OptionPane « Swing JFC « Java
- Java
- Swing JFC
- OptionPane
Modal dialog with OK/cancel 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
}
}
}
Related examples in the same category