⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useradd.java~2~

📁 若已安装Jbuilder X
💻 JAVA~2~
字号:
package Manager;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class userAdd extends JFrame {   private DBManager db =new DBManager();//定义数据库操作对象  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel2 = new JLabel();  JButton jButtonCancel = new JButton();  JLabel jLabel1 = new JLabel();  JTextField jTextFieldusername = new JTextField();  JButton jButtonOK = new JButton();  JPasswordField jPasswordold = new JPasswordField();  JLabel jLabel3 = new JLabel();  JPasswordField jPasswordnew = new JPasswordField();  public userAdd() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  public static void main(String[] args) {    userAdd userAdd = new userAdd();  }  private void jbInit() throws Exception {    jPasswordold.setText("");    jButtonOK.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonOK.addMouseListener(new userAdd_jButtonOK_mouseAdapter(this));    jButtonOK.setText("添加");    jButtonOK.addMouseListener(new userAdd_jButtonOK_mouseAdapter(this));    jTextFieldusername.setFont(new java.awt.Font("Dialog", 0, 16));    jTextFieldusername.setText("");    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("用户名");    jButtonCancel.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonCancel.addMouseListener(new userAdd_jButtonCancel_mouseAdapter(this));    jButtonCancel.setText("取消");    jButtonCancel.addMouseListener(new userAdd_jButtonCancel_mouseAdapter(this));    jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel2.setText("密码");    xYLayout1.setWidth(480);    xYLayout1.setHeight(288);    this.getContentPane().setLayout(xYLayout1);    jLabel3.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel3.setText("确认密码");    jPasswordnew.setFont(new java.awt.Font("Dialog", 0, 16));    jPasswordnew.setText("");    this.getContentPane().add(jTextFieldusername, new XYConstraints(263, 32, 111, 38));    this.getContentPane().add(jLabel2, new XYConstraints(113, 99, 80, 34));    this.getContentPane().add(jLabel1, new XYConstraints(112, 33, 99, 34));    this.getContentPane().add(jPasswordold, new XYConstraints(264, 95, 111, 35));    this.getContentPane().add(jPasswordnew,  new XYConstraints(261, 157, 117, 35));    this.getContentPane().add(jLabel3, new XYConstraints(108, 160, 110, 36));    this.getContentPane().add(jButtonOK, new XYConstraints(136, 231, 91, 31));    this.getContentPane().add(jButtonCancel, new XYConstraints(254, 232, 94, 30));  }   //退出此窗口  void jButtonCancel_mouseClicked(MouseEvent e) {         this.dispose();  }  //添加新用户  void jButtonOK_mouseClicked(MouseEvent e) {    String strSQL ;    //校验用户两次输入的密码是否一致              strSQL="insert into  user(username,password) values('"+jTextFieldusername.getText().trim() +"','"+jPasswordold.getText().trim()+"')";                  if(db.executeSql(strSQL))                     {JOptionPane.showMessageDialog(null,"成功添加!"); }                  else                     { JOptionPane.showMessageDialog(null," 添加失败,请重新操作!");      }  }}class userAdd_jButtonCancel_mouseAdapter extends java.awt.event.MouseAdapter {  userAdd adaptee;  userAdd_jButtonCancel_mouseAdapter(userAdd adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonCancel_mouseClicked(e);  }}class userAdd_jButtonOK_mouseAdapter extends java.awt.event.MouseAdapter {  userAdd adaptee;  userAdd_jButtonOK_mouseAdapter(userAdd adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonOK_mouseClicked(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -