나는 사용자가 모든 필드를 삽입하거나하지 않은 경우 어떻게 확인합니까 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 , , "
왜 필드에 'null'확인을 수행하지 않고 3 개의 필드 중 하나라도 null이면 모든 필드가 필요하다는 것을 나타내는 대화 상자를 다시 표시하십시오. – mre
참조 : http://stackoverflow.com/questions/4608124/how-to-assign-a-sepecifc-action-to-the-cancel-button-within-joptionpane-show –
감사합니다. 닫기 작업에 대해 – sanu