我創建了需要3場如何檢查用戶是否在JDialogBox中輸入了某些內容?
public class Test{
public static void main(String args[])
{
JTextField firstName = new JTextField();
JTextField lastName = new JTextField();
JPasswordField password = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
new JLabel("First"),
firstName,
new JLabel("Last"),
lastName,
new JLabel("Password"),
password
};
JOptionPane.showMessageDialog(null, inputs, "My custom dialog",JOptionPane.PLAIN_MESSAGE);
System.out.println("You entered " +firstName.getText() + ", " +lastName.getText() + ", " +password.getText());
}
}
如何檢查,如果用戶插入的所有字段或不是自定義對話框?而且,即使用戶關閉對話框,它顯示
You entered , ,
我要檢查用戶輸入的字段和關閉應用程序,如果沒有dsplaying
"You entered , , "
爲什麼不對這些字段執行'null'檢查,如果這3個字段中的任何一個爲空,則再次顯示對話框,指示所有字段都是必需的。 – mre 2011-06-13 11:52:42
請參閱:http://stackoverflow.com/questions/4608124/how-to-assign-a-sepecifc-action-to-the-cancel-button-within-joptionpane-show – 2011-06-13 11:53:04
謝謝,我明白了......但是什麼關於關閉操作 – sanu 2011-06-13 11:54:24