该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package javaxm;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;public class Test1 extends JFrame implements ActionListener{
static Test t = new Test();
static User u = new User();
static Dao d = new Dao();
static Test1 one = new Test1();
JButton btnOK;
JButton btnCancel;
JButton close;
JTextField tf1;
JTextField tf2;
public Test1(){
setSize(400,300);
setLayout(new FlowLayout());
setLocation(600, 300);
JLabel lab1=new JLabel("账号:");
tf1=new JTextField(10);
JLabel lab2=new JLabel("密码:");
tf2=new JTextField(10);
btnOK=new JButton("登录");
btnOK.addActionListener(this);
btnCancel=new JButton("退出");
btnCancel.addActionListener(this);
Container c=this.getContentPane();
c.add(lab1);
c.add(tf1);
c.add(lab2);
c.add(tf2);
c.add(btnOK);
c.add(btnCancel);
setVisible(true);
}
public static void main(String[] args){
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btnOK){
String account=tf1.getText();
String pwd=tf2.getText();
u=d.login(account,pwd);
if(u!=null)
{
JOptionPane.showMessageDialog(null, "登录成功");
one.get();
t.ifLogin();
setVisible(false);
//new Test1().setVisible(true);
// this.dispose();
}
else
JOptionPane.showMessageDialog(null, "登录失败");
}
else if(e.getSource()==btnCancel)
{
System.exit(0);
}
}
public int get()
{
return u.getQx();
}
}