📄 zhujiemian.java
字号:
package don;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
public class zhujiemian implements ActionListener
{
//private static final Color RED = null;
JFrame fra=new JFrame("学生管理系统");
JLabel l1=new JLabel("用户名");
JLabel l2=new JLabel("密码");
JTextField t1=new JTextField(0);
JPasswordField t2=new JPasswordField(0);
JButton b1=new JButton("登录");
JButton b2=new JButton("退出");
JLabel l3=new JLabel(" 管 理 员");
JLabel l4=new JLabel(" 学 生");
JRadioButton r1=new JRadioButton();
JRadioButton r2=new JRadioButton();
public zhujiemian()
{
((JFrame) fra).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fra.setBounds(0,0,700,500);//设置窗口显示的坐标及位置
fra.setResizable(false);//设置窗口的尺寸不可改变
JPanel p1=new JPanel();
JPanel p3=new JPanel();
Font[] fonts={new Font("粗体",Font.LAYOUT_RIGHT_TO_LEFT,32)};
String arg0=("学 生 管 理 系 统");
JLabel l6=new JLabel();
l6.setFont(fonts[0]);
l6.setText(arg0);
ImageIcon xiaohui=new ImageIcon("ligong.jpg");
JLabel l5=new JLabel(xiaohui);
ButtonGroup group1=new ButtonGroup();
final JRadioButton r1=new JRadioButton();
final JRadioButton r2=new JRadioButton();
r1.setBounds(110, 400, 20, 20);
r2.setBounds(300, 400, 20, 20);
group1.add(r1);
group1.add(r2);
fra.setLayout(null);
p1.setBounds(0, 0, 700, 500);
p1.setLayout(null);
l1.setBounds(50, 300, 100, 25);
l2.setBounds(270, 300, 100, 25);
t1.setBounds(100, 300, 150, 25);
t2.setBounds(310, 300, 150, 25);
b1.setBounds(500, 300,100, 25);
b2.setBounds(500, 400, 100, 25);
l3.setBounds(140, 400, 100, 25);
l4.setBounds(330, 400, 100, 25);
l5.setBounds(0, 1, 700, 90);
l6.setBounds(200, 180, 300, 50);
fra.add (p1);
p1.add (l1);
p1.add(l2);
p1.add(t1);
p1.add(t2);
p1.add(b1);
p1.add(b2);
p1.add(r1);
p1.add(r2);
p1.add(l3);
p1.add(l4);
p1.add(l6);
p1.add (l5);
fra.setVisible(true);//显示窗口
r1.addActionListener(this);
r2.addActionListener(this);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
final String a;
final String b;
a=t1.getText();
b=t2.getText();
DBSource db=new DBSource();
if(r1.isSelected())
{
String sql="select * from guanliyuan where dengluming='" + a + "' and gmima='" + b + "'";
ResultSet rs1=db.executeQuery(sql);
try {
if(rs1.next())
{
new guanliyuanjiemian();
}
else
{
JOptionPane.showMessageDialog(fra,"管理员用户名或者密码输入有误!");
return;
}
} catch (SQLException e1){e1.printStackTrace();}
}
if(r2.isSelected())
{
String sql="select * from geren where sno='" + a + "' and smima='" + b + "'";
ResultSet rs2=db.executeQuery(sql);
try
{
if(rs2.next()){
new studentchaxun(a);
}
else
{
JOptionPane.showMessageDialog(fra,"学生用户名或者密码输入有误!");
return;
}
}
catch (SQLException e1) {e1.printStackTrace();}
}
}
});
b2.addActionListener(this);
t1.addActionListener(this);
t2.addActionListener(this);
}
public static void main(String[] args)
{
new zhujiemian();
}
public void actionPerformed(final ActionEvent e)
{
if(e.getSource()==b2)
{
System.exit(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -