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

📄 zcfrm.java

📁 JAVA编写的登陆窗体
💻 JAVA
字号:
package loginexample;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class zcfrm extends JFrame {
    public zcfrm() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel1.setText("jLabel1");
        jLabel1.setBounds(new Rectangle(29, 44, 84, 30));
        jPasswordField1.setBounds(new Rectangle(165, 133, 138, 38));
        jPasswordField2.setBounds(new Rectangle(162, 205, 139, 38));
        jButton2.addActionListener(new zcfrm_jButton2_actionAdapter(this));
        this.getContentPane().add(jLabel1);
        jButton2.setBounds(new Rectangle(212, 272, 131, 39));
        jButton2.setText("关闭");
        jButton1.setBounds(new Rectangle(43, 274, 131, 39));
        jButton1.setText("确定");
        jButton1.addActionListener(new zcfrm_jButton1_actionAdapter(this));
        jLabel3.setText("jLabel3");
        jLabel3.setBounds(new Rectangle(30, 214, 84, 30));
        jLabel2.setText("jLabel2");
        jLabel2.setBounds(new Rectangle(28, 129, 84, 30));
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        this.getContentPane().add(jPasswordField1);
        this.getContentPane().add(jPasswordField2);
        jTextField1.setBounds(new Rectangle(164, 46, 138, 36));
    }

    public static void main(String[] args) {
        zcfrm zcfrm = new zcfrm();
    }

    JLabel jLabel1 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JPasswordField jPasswordField1 = new JPasswordField();
    JPasswordField jPasswordField2 = new JPasswordField();
    //
    DBCON dbcon = new DBCON();
    public void jButton1_actionPerformed(ActionEvent e) {
        String strname = jTextField1.getText().trim();
        char ch1[] = jPasswordField1.getPassword();
        String strnewpass1 = new String(ch1);
        char ch2[] = jPasswordField2.getPassword();
        String strnewpass2 = new String(ch2);
        if (strnewpass1.equals(strnewpass2)) {
            boolean b = dbcon.insertuser(strname, strnewpass1);
            if (b == true) {
                JOptionPane.showMessageDialog(this, "注册成功");
            } else {
                JOptionPane.showMessageDialog(this, "失败!");
            }
        } else {
            JOptionPane.showMessageDialog(this, "密码不一致!");
        }

    }

    public void jButton2_actionPerformed(ActionEvent e) {
        this.dispose();
    }
}


class zcfrm_jButton2_actionAdapter implements ActionListener {
    private zcfrm adaptee;
    zcfrm_jButton2_actionAdapter(zcfrm adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class zcfrm_jButton1_actionAdapter implements ActionListener {
    private zcfrm adaptee;
    zcfrm_jButton1_actionAdapter(zcfrm adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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