📄 dengluframe1.java~44~
字号:
package student;
import java.awt.BorderLayout;
import javax.swing.*;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Statement;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class dengluFrame1 extends JFrame {
public static String name;
public static String pass;
public dengluFrame1() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Dialog", Font.BOLD, 20));
jLabel1.setForeground(Color.magenta);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("欢迎进入学生信息管理系统");
jLabel1.setBounds(new Rectangle(33, 22, 313, 47));
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton1.addActionListener(new dengluFrame1_jButton1_actionAdapter(this));
ZC.setBounds(new Rectangle(219, 212, 92, 33));
ZC.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
ZC.setToolTipText("");
ZC.setText("注册用户");
ZC.addActionListener(new dengluFrame1_ZC_actionAdapter(this));
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton2.addActionListener(new dengluFrame1_jButton2_actionAdapter(this));
this.getContentPane().setBackground(Color.cyan);
this.setForeground(SystemColor.control);
this.getContentPane().add(jLabel1);
jButton2.setBounds(new Rectangle(120, 213, 80, 32));
jButton2.setText("离开");
jButton1.setBounds(new Rectangle(27, 213, 80, 32));
jButton1.setText("登陆");
MM.setBounds(new Rectangle(99, 145, 161, 37));
YH.setBounds(new Rectangle(101, 80, 157, 38));
jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel3.setText("密码 ");
jLabel3.setBounds(new Rectangle(16, 136, 97, 41));
this.getContentPane().add(jLabel2);
this.getContentPane().add(jLabel3);
this.getContentPane().add(YH);
this.getContentPane().add(MM);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.getContentPane().add(ZC);
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel2.setText("用户名");
jLabel2.setBounds(new Rectangle(15, 78, 90, 34));
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField YH = new JTextField();
JPasswordField MM = new JPasswordField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
javax.swing.JButton ZC = new JButton();
public void jButton1_actionPerformed(ActionEvent e) {
String yh=YH.getText();
int flag=0;
String mm=new String(MM.getPassword());
Connectionsql ss=new Connectionsql();
try{
Connection con=ss.getConnection();
Statement stmt=con.createStatement();
String sql="select zhanghao,mima from zhanghu";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
if(yh.equals(rs.getString(1))&&(mm.equals(rs.getString(2)))){
flag=1;
name=rs.getString(1);
pass=rs.getString(2);
JOptionPane.showMessageDialog(this, "恭喜您登陆成功!", "成功",
JOptionPane.INFORMATION_MESSAGE);
mainFrame s=new mainFrame();
s.setSize(600,500);
s.show();
this.dispose();
}
} if(flag==0){
YH.setText("");
MM.setText("");
JOptionPane.showMessageDialog(this,"帐号或者密码错误!","失败",JOptionPane.ERROR_MESSAGE);
}
}catch(Exception ce){
ce.printStackTrace();
}
if(yh.equals("houjian")){
mainFrame s10=new mainFrame();
s10.setVisible(true);
s10.setEnabled(true);
}else{
mainFrame s11=new mainFrame();
s11.xxchaxun.setVisible(false);
s11.xxchaxun.setEnabled(false);
}
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void ZC_actionPerformed(ActionEvent e) {
zhuceFrame1 qq=new zhuceFrame1();
qq.setTitle("注册新用户");
qq.setSize(400,300);
qq.setVisible(true);
qq.show();
}
}
class dengluFrame1_ZC_actionAdapter implements ActionListener {
private dengluFrame1 adaptee;
dengluFrame1_ZC_actionAdapter(dengluFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.ZC_actionPerformed(e);
}
}
class dengluFrame1_jButton2_actionAdapter implements ActionListener {
private dengluFrame1 adaptee;
dengluFrame1_jButton2_actionAdapter(dengluFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class dengluFrame1_jButton1_actionAdapter implements ActionListener {
private dengluFrame1 adaptee;
dengluFrame1_jButton1_actionAdapter(dengluFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -