- 434 名前:デフォルトの名無しさん mailto:sage [2009/03/20(金) 01:56:28 ]
- final JTextField textField = new JTextField("Hello");
JOptionPane pane = new JOptionPane(textField, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog("Input Text"); dialog.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { textField.requestFocusInWindow(); } }); dialog.setVisible(true); dialog.dispose(); Object o = pane.getValue(); int result = (o instanceof Integer) ? (Integer)o : JOptionPane.CLOSED_OPTION; うそくさいし、ひどく面倒
|

|