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

📄 usermanager_dialog.java

📁 library-manage-system(图书管理系统),很好的学习源码。
💻 JAVA
字号:
package library;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import com.borland.dbswing.*;import com.borland.dx.sql.dataset.*;import java.awt.event.*;import java.util.Date;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class UserManager_Dialog extends JDialog {  private JPanel panel1 = new JPanel();  private Database database1 = new Database();  private QueryDataSet queryDataSet1 = new QueryDataSet();  private JPasswordField jPasswordField1 = new JPasswordField();  private JPasswordField jPasswordField2 = new JPasswordField();  private JLabel jLabel1 = new JLabel();  private JLabel jLabel2 = new JLabel();  private JLabel jLabel3 = new JLabel();  private JTextField jTextField1 = new JTextField();  private JButton jButton1 = new JButton();  private JButton jButton2 = new JButton();  private GridBagLayout gridBagLayout1 = new GridBagLayout();  public UserManager_Dialog(Frame frame, String title, boolean modal) {    super(frame, title, modal);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public UserManager_Dialog() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(gridBagLayout1);    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:lib", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));    database1.setDatabaseName("");    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from user", null, true, Load.ALL));    jLabel1.setFont(new java.awt.Font("DialogInput", 0, 12));    jLabel1.setText("用户名:");    jLabel2.setText("口  令:");    jLabel2.setFont(new java.awt.Font("DialogInput", 0, 12));    jLabel3.setText("确  认:");    jLabel3.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton1.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton1.setText("注册");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jButton2.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton2.setText("取消");    jButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton2_actionPerformed(e);      }    });    this.setResizable(false);    this.setTitle("注册");    getContentPane().add(panel1);    panel1.add(jLabel3,  new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 47, 0, 18), 0, 0));    panel1.add(jLabel1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(56, 47, 0, 21), 0, 0));    panel1.add(jLabel2,  new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(24, 47, 0, 19), 0, 0));    panel1.add(jTextField1,    new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(56, 3, 0, 71), 114, 0));    panel1.add(jButton1,  new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(38, 57, 22, 0), 0, 0));    panel1.add(jButton2,  new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(40, 61, 22, 93), 0, 0));    panel1.add(jPasswordField1,   new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(17, 4, 0, 71), 109, 0));    panel1.add(jPasswordField2,     new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(13, 5, 0, 71), 108, 0));  }  void jButton1_actionPerformed(ActionEvent e) {    if(jTextField1.getText().length()==0)    {      JOptionPane.showMessageDialog(this,"请输入用户名!","提示",JOptionPane.ERROR_MESSAGE);      return;    }    if(jPasswordField1.getText().length()==0)    {      JOptionPane.showMessageDialog(this,"请输入口令!","提示",JOptionPane.ERROR_MESSAGE);      return;    }    if(!jPasswordField1.getText().equalsIgnoreCase(jPasswordField2.getText()))    {      JOptionPane.showMessageDialog(this,"您输入的两次口令不一致,请重新输入!","提示",JOptionPane.ERROR_MESSAGE);      return;    }    if(!queryDataSet1.isOpen())      queryDataSet1.open();    try{      queryDataSet1.insertRow(false);      queryDataSet1.setString("name",jTextField1.getText());      queryDataSet1.setString("pass",jPasswordField1.getText());      queryDataSet1.post();      queryDataSet1.saveChanges();      queryDataSet1.close();      JOptionPane.showMessageDialog(this,"注册成功!","提示",JOptionPane.INFORMATION_MESSAGE);    }catch(Exception ex)    {      JOptionPane.showMessageDialog(this,"注册失败!","提示",JOptionPane.ERROR_MESSAGE);      queryDataSet1.refresh();      return;    }    this.dispose();  }  void jButton2_actionPerformed(ActionEvent e) {    this.dispose();  }}

⌨️ 快捷键说明

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