📄 zhuceframe1.java
字号:
package student;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Statement;
import java.sql.Connection;
import java.util.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class zhuceFrame1 extends JFrame {
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField yh = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JPasswordField mm = new JPasswordField();
JLabel jLabel3 = new JLabel();
JPasswordField mm2 = new JPasswordField();
JLabel jLabel4 = new JLabel();
JComboBox leixing = new JComboBox();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
public zhuceFrame1() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jPanel1.setLayout(null);
jPanel1.setBackground(Color.pink);
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setBounds(new Rectangle(21, 14, 355, 265));
jButton1.setBounds(new Rectangle(55, 208, 104, 36));
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jButton1.setText("确定");
jButton1.addActionListener(new zhuceFrame1_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(178, 207, 118, 36));
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jButton2.setText("取消");
jButton2.addActionListener(new zhuceFrame1_jButton2_actionAdapter(this));
jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
mm.setBounds(new Rectangle(111, 67, 163, 35));
jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel3.setText("确认密码");
jLabel3.setBounds(new Rectangle(16, 113, 89, 38));
mm2.setBounds(new Rectangle(112, 117, 165, 36));
jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel4.setText("用户类型");
jLabel4.setBounds(new Rectangle(9, 164, 75, 34));
leixing.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
leixing.setBounds(new Rectangle(112, 167, 98, 26));
jLabel5.setText("jLabel5");
jLabel5.setBounds(new Rectangle(0, 0, 34, 16));
jLabel6.setText("jLabel6");
jLabel6.setBounds(new Rectangle(3, 3, 347, 258));
this.getContentPane().setBackground(Color.white);
this.getContentPane().add(jPanel1, null);
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(14, 62, 80, 39));
yh.setText("");
yh.setBounds(new Rectangle(111, 10, 159, 34));
jPanel1.add(jButton1);
jPanel1.add(jButton2);
jPanel1.add(yh);
jPanel1.add(jLabel1);
jPanel1.add(mm);
jPanel1.add(mm2);
jPanel1.add(jLabel4);
jPanel1.add(leixing);
jPanel1.add(jLabel3);
jPanel1.add(jLabel2);
jPanel1.add(jLabel6);
jLabel1.setText("用户名");
jLabel1.setBounds(new Rectangle(14, 14, 90, 34));
leixing.addItem("普通用户");
leixing.addItem("超级用户");
jButton1.setIcon(new ImageIcon("an086.gif"));
jButton2.setIcon(new ImageIcon("an088.gif"));
jLabel6.setIcon(new ImageIcon("11.jpg"));
}
public void jButton2_actionPerformed(ActionEvent e) {
this.dispose();
}
public void jButton1_actionPerformed(ActionEvent e) {
String YH = yh.getText();
String MM1;
String MM;
MM = mm.getText();
MM1= mm2.getText();
String LX=(String)leixing.getSelectedItem();
if (YH.length() == 0) {
JOptionPane.showMessageDialog(this, "请输入用户名", "错误",
JOptionPane.INFORMATION_MESSAGE);
return;
}
if (MM.length()==0) {
JOptionPane.showMessageDialog(this, "请输入密码", "错误",
JOptionPane.INFORMATION_MESSAGE);
return;
}
if(MM.equals(MM1)){
JOptionPane.showMessageDialog(this,"注册成功");
}else {
JOptionPane.showMessageDialog(this,"密码错误");
return;
}
Connectionsql ss = new Connectionsql();
try {
Connection con = ss.getConnection();
Statement stmt = con.createStatement();
String sql = "insert into zhanghu(zhanghao,mima,quanxian) values ('"+YH+"','"+MM1+"','"+LX+"')";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null, "注册成功");
this.dispose();
} catch (Exception ce) {
ce.printStackTrace();
}
}
class zhuceFrame1_jButton1_actionAdapter implements ActionListener {
private zhuceFrame1 adaptee;
zhuceFrame1_jButton1_actionAdapter(zhuceFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class zhuceFrame1_jButton2_actionAdapter implements ActionListener {
private zhuceFrame1 adaptee;
zhuceFrame1_jButton2_actionAdapter(zhuceFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -