3つのフィールドを必要とするカスタムダイアログボックスを作成しました
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 , ,
フィールドへのユーザー入力を確認し、ユーザーがdsplayを使用せずにダイアログボックスを閉じる場合はアプリケーションを閉じたい
"You entered , , "