好的。我正在制作一个用于在计算机上进行管理的软件。使人们能够根据他们的许可登录并做一些事情。到目前为止,我拥有的是一个由所有用户组成的阵列系统,其中包含用户名、密码和权限。我想要做的是从一个java swing窗口(我已经在其中编程)并将该窗口中的用户名和密码与所有数组进行比较并检查匹配。任何帮助将不胜感激。谢谢。我的代码:
public class Main {
public static void main(String[]args){
WindowLogin.openWindow();
}
}
public class Database {
public static String[] userAdmin = {"admin","admin","10"}; //Username password clearance
public static String[] userAlexander = {"Alexander","1234","1"}; //Same stuff here
}
import javax.swing.*;
import java.awt.*;
public class WindowLogin {
public static void openWindow(){
JFrame f = new JFrame("Login");
JTextField userName = new JTextField(20);
JPasswordField password = new JPasswordField();
JPanel info = new JPanel(new GridLayout(2,1,5,5));
JPanel lnPanel = new JPanel(new GridLayout(1,1,5,5));
JButton lnButton = new JButton("Log in");
info.add(userName);
info.add(password);
lnPanel.add(lnButton);
f.setLayout(new FlowLayout());
f.setResizable(false);
f.add(info);
f.add(lnPanel);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
}