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

📄 register.java

📁 java 写的一个地址薄管理工具
💻 JAVA
字号:
/* * register.java * * Created on 2007年12月20日, 下午10:13 */package com.sxy.frame;import com.sxy.database.*;import com.sxy.database.DabaCon;import javax.swing.JOptionPane;/** * * @author  Arthur */public class register extends javax.swing.JFrame {    /** Creates new form register */    public register() {        initComponents();    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jPanel1 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        username = new javax.swing.JTextField();        jPanel2 = new javax.swing.JPanel();        jLabel2 = new javax.swing.JLabel();        password_1 = new javax.swing.JPasswordField();        jPanel3 = new javax.swing.JPanel();        jLabel3 = new javax.swing.JLabel();        password_2 = new javax.swing.JPasswordField();        jPanel4 = new javax.swing.JPanel();        register = new javax.swing.JButton();        jLabel4 = new javax.swing.JLabel();        reset = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);        setTitle("请注册!!");        setAlwaysOnTop(true);        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));        setLocationByPlatform(true);        setResizable(false);        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                winclosing(evt);            }        });        getContentPane().setLayout(new java.awt.FlowLayout());        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);        jLabel1.setText("用户名:  ");        jPanel1.add(jLabel1);        username.setColumns(20);        username.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                usernameActionPerformed(evt);            }        });        jPanel1.add(username);        getContentPane().add(jPanel1);        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);        jLabel2.setText("密  码:  ");        jPanel2.add(jLabel2);        password_1.setColumns(20);        jPanel2.add(password_1);        getContentPane().add(jPanel2);        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);        jLabel3.setText("确认密码:");        jPanel3.add(jLabel3);        password_2.setColumns(20);        password_2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                password_2ActionPerformed(evt);            }        });        jPanel3.add(password_2);        getContentPane().add(jPanel3);        register.setText("注册");        register.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                registerActionPerformed(evt);            }        });        jPanel4.add(register);        jLabel4.setText("           ");        jPanel4.add(jLabel4);        reset.setText("重填");        reset.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                resetActionPerformed(evt);            }        });        jPanel4.add(reset);        getContentPane().add(jPanel4);        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();        setBounds((screenSize.width-300)/2, (screenSize.height-200)/2, 300, 200);    }// </editor-fold>//GEN-END:initComponents    private void password_2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_password_2ActionPerformed    // TODO add your handling code here:    }//GEN-LAST:event_password_2ActionPerformed    private void usernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameActionPerformed    // TODO add your handling code here:    }//GEN-LAST:event_usernameActionPerformed    private void registerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerActionPerformed        String name = username.getText();        String pass1 = new String(password_1.getPassword());        String pass2 = new String(password_2.getPassword());        person p = new person();        p.setName(name);        p.setPassword(pass1);        DabaCon con = new DabaCon();        con.condata();        boolean flag = con.isexist(name);        if (!flag && !name.equals("") && !pass1.equals("") && !pass2.equals("")) {            if (pass1.equals(pass2)) {                con.addUser(p);                int i = JOptionPane.showConfirmDialog(this, "注册成功,点击确定进入主窗口", "系统提示", JOptionPane.YES_NO_OPTION, JOptionPane.DEFAULT_OPTION);                if (i == JOptionPane.YES_OPTION) {                    AddBookMain book = new AddBookMain(name);                    book.setVisible(true);                    this.dispose();                } else {                    this.dispose();                }            } else {                JOptionPane.showMessageDialog(this, "密码不一致,请仔细检查!!", "系统提示", JOptionPane.ERROR_MESSAGE);                password_1.setText("");                password_2.setText("");            }        } else {            if (name.equals("")) {                JOptionPane.showMessageDialog(this, "用户名不能为空!!", "系统提示", JOptionPane.ERROR_MESSAGE);            } else {                JOptionPane.showMessageDialog(this, "用户名已存在!!", "系统提示", JOptionPane.ERROR_MESSAGE);            }            username.setText("");            password_1.setText("");            password_2.setText("");        }        con.close();    // TODO add your handling code here:    }//GEN-LAST:event_registerActionPerformed    private void resetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetActionPerformed        username.setText("");        password_1.setText("");        password_2.setText("");    // TODO add your handling code here:    }//GEN-LAST:event_resetActionPerformed    private void winclosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_winclosing        new Login().setVisible(true);        this.dispose();    // TODO add your handling code here:    }//GEN-LAST:event_winclosing    /**     * @param args the command line arguments     */  /*   public static void main(String args[]) {    try {    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());    new register().setVisible(true);    } catch (ClassNotFoundException ex) {    Logger.getLogger(register.class.getName()).log(Level.SEVERE, null, ex);    } catch (InstantiationException ex) {    Logger.getLogger(register.class.getName()).log(Level.SEVERE, null, ex);    } catch (IllegalAccessException ex) {    Logger.getLogger(register.class.getName()).log(Level.SEVERE, null, ex);    } catch (UnsupportedLookAndFeelException ex) {    Logger.getLogger(register.class.getName()).log(Level.SEVERE, null, ex);    }    }*/    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JLabel jLabel4;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    private javax.swing.JPanel jPanel4;    private javax.swing.JPasswordField password_1;    private javax.swing.JPasswordField password_2;    private javax.swing.JButton register;    private javax.swing.JButton reset;    private javax.swing.JTextField username;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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