?? 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("學(xué)生管理系統(tǒng)");
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(" 學(xué) 生");
JRadioButton r1=new JRadioButton();
JRadioButton r2=new JRadioButton();
public zhujiemian()
{
((JFrame) fra).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fra.setBounds(0,0,700,500);//設(shè)置窗口顯示的坐標(biāo)及位置
fra.setResizable(false);//設(shè)置窗口的尺寸不可改變
JPanel p1=new JPanel();
JPanel p3=new JPanel();
Font[] fonts={new Font("粗體",Font.LAYOUT_RIGHT_TO_LEFT,32)};
String arg0=("學(xué) 生 管 理 系 統(tǒng)");
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,"學(xué)生用戶名或者密碼輸入有誤!");
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);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -