非数据库的
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UserFrame extends JFrame {
public UserFrame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
lblName.setText("用户名:");
lblName.setBounds(new Rectangle(26, 52, 60, 32));
btnOK.setBounds(new Rectangle(38, 196, 91, 38));
btnOK.setText("确定");
btnOK.addActionListener(new UserFrame_btnOK_actionAdapter(this));
btnCencal.setBounds(new Rectangle(173, 196, 91, 37));
btnCencal.setText("取消");
btnCencal.addActionListener(new UserFrame_btnCencal_actionAdapter(this));
txtName.setBounds(new Rectangle(126, 52, 111, 31));
txtPWD.setBounds(new Rectangle(126, 135, 110, 31));
lblMessage.setBounds(new Rectangle(83, 92, 165, 28));
this.getContentPane().add(lblName);
this.getContentPane().add(lblPWD);
this.getContentPane().add(btnOK);
this.getContentPane().add(btnCencal);
this.getContentPane().add(txtName);
this.getContentPane().add(txtPWD);
this.getContentPane().add(lblMessage);
lblPWD.setText("密码:");
lblPWD.setBounds(new Rectangle(26, 131, 70, 37));
}
JLabel lblName = new JLabel();
JLabel lblPWD = new JLabel();
JButton btnOK = new JButton();
JButton btnCencal = new JButton();
JTextField txtName = new JTextField();
JTextField txtPWD = new JTextField();
JLabel lblMessage = new JLabel();
public void btnOK_actionPerformed(ActionEvent e) {
String User;
String PWD;
User=txtName.getText();
PWD=txtPWD.getText();
if(User.equals("admin")&&PWD.equals("admin888")){
lblMessage.setText("登陆成功");
AddUserinfo au = new AddUserinfo();
au.setTitle("信息修改器");
au.setBounds(50, 50, 400, 310);
au.setVisible(true);
this.dispose();
}else{
lblMessage.setText("登陆失败");
}
}
public void btnCencal_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class UserFrame_btnCencal_actionAdapter implements ActionListener {
private UserFrame adaptee;
UserFrame_btnCencal_actionAdapter(UserFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnCencal_actionPerformed(e);
}
}
class UserFrame_btnOK_actionAdapter implements ActionListener {
private UserFrame adaptee;
UserFrame_btnOK_actionAdapter(UserFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnOK_actionPerformed(e);
}
public static void main(String [] args){
UserFrame uf=new UserFrame();
uf.setBounds(0,0,350,300);
uf.setTitle("登陆器");
uf.setVisible(true);
}
}