package com.lzy;
/*
* 登录窗口
*/
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import com.lzy.adm.AdminView;
import com.lzy.sql.GetSQL;
import com.lzy.stuExam.Student;
LoginView(){
//注册监听
jb1.addActionListener(this);
jb2.addActionListener(this);
//透明按钮
jrb1.setContentAreaFilled(false);
jrb2.setContentAreaFilled(false);
//按钮组
bg.add(jrb1);
bg.add(jrb2);
//注册监听
jrb1.addActionListener(this);
jrb2.addActionListener(this);
jp1.add(jlb1);
jp1.add(jtf);
jp2.add(jlb2);
jp2.add(jpf);
jp3.add(jlb3);
jp3.add(jrb1);
jp3.add(jrb2);
jp4.add(jb1);
jp4.add(jb2);
jp1.setBackground(color);
jp2.setBackground(color);
jp3.setBackground(color);
jp4.setBackground(color);
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.setTitle("在线考试系统");
this.setSize(300,250);
this.setLocationRelativeTo(null);
this.setVisible(true);
this.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE);
}
@Override
// TODO Auto-generated method stub
if(e.getActionCommand()=="退出"){
}else {
if(e.getActionCommand()=="登录"){
if(!(jtf.getText().isEmpty()) && !(jpf.getText().isEmpty())){
//连接数据库
GetSQL.connectSQL();
//权限选择
if(jrb1.isSelected()){
//查找用户
GetSQL.stu(jtf.getText());
if(GetSQL.pwd==null){
this.clear();
}else {
if(GetSQL.pwd.equals(jpf.getText().trim())){
this.clear();
this.dispose();
new Student();
}else {
this.clear();
}
}
}
//权限选择
if(jrb2.isSelected()){
//查找用户
GetSQL.adm(jtf.getText());
if(GetSQL.pwd==null){
this.clear();
}else {
if(GetSQL.pwd.equals(jpf.getText().trim())){
this.clear();
this.dispose();
new AdminView();
}else {
this.clear();
}
}
}
}else {
this.clear();
}
}
}
}
//清空
private void clear(){
jtf.setText("");
jpf.setText("");
}
// public static void main (String args[]){
// new Login();
// }
}
package com.lzy;
public class Main {
public static void main
(String args
[]){
new LoginView();
}
}