2 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
這是我的解決方案
JTextField username = new JTextField();
JTextField password = new JPasswordField();
Object[] message = {
"Username:", username,
"Password:", password
};
int option = JOptionPane.showConfirmDialog(null, message, "Login", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
if (username.getText().equals("h") && password.getText().equals("h")) {
System.out.println("Login successful");
} else {
System.out.println("login failed");
}
} else {
System.out.println("Login canceled");
}
添加回答
舉報(bào)