0
ublic class TheMedicalResourceManagementSystem
{
JFrame jf;
JPanel jp;
JButton b;
JTextField t;
JTextField t2;
public static void main(String[] args)
{
TheMedicalResourceManagementSystem cc = new TheMedicalResourceManagementSystem();
// SwingUtilities.invokeLater(() -> new GUI("The Medical Resource Management System").setVisible(true));
}
public TheMedicalResourceManagementSystem()
{
jf = new JFrame("Frame");
jp = new JPanel();
jp.setLayout(new FlowLayout());
jf.add(jp);
t = new JTextField(15);
jp.add(t);
t2 = new JTextField(15);
jp.add(t);
jp.add(t2);
b= new JButton("Login");
jp.add(b);
jf.setSize(200,200);
jf.setVisible(true);
String username = t.getText();
String password = t2.getText();
b.addActionListener((ActionEvent e) -> {
if(username.equals("admin") && password.equals("password"))
{
SwingUtilities.invokeLater(() -> new GUI("Medical Remote Management System").setVisible(true));
}
else
{
JOptionPane.showMessageDialog(null, "Incorrect username or password , Please try again");
}});
}
}
내 프로그램 내에서 사용자 이름과 암호를 입력하려고하고 있는데 입력하고 올바르게 입력하면 모든 사항이 실행됩니다. 관리자가 아니고 암호가 잘못 되었더라도 사용자 나 암호가 잘못되었다고 계속해서 말하면서 관리자와 암호를 입력 할 때처럼 실행되지는 않습니까?JTextField 및 JButton 로그인 페이지
이 근무는
ActionEvent
시의username
및password
을 얻을 필요가! 이 양식을 어떻게 숨길까요? if에서 dispose를 사용하는 것이 포함됩니까? – YeBoi글쎄, 당신의 경우, 나는 "모달 대화 상자"를 사용하여 몇 가지 연구를 해보 겠지만, 당신이 마주 치려고하는 다른 문제를 해결할 것입니다. 그렇습니다. '처분'은 윈도우를 처분하는 가장 일반적인 방법이 될 것입니다. 오래 걸리는 – MadProgrammer