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

📄 login.java~18~

📁 代码是自己我的代码不是网上down的。是自己写的。里面有很多值得学习的知识点。还有一些javabean组件。不算自己写的JAR文件
💻 JAVA~18~
字号:
package zcgl;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import java.sql.*;
import javax.swing.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Login extends JFrame {
    BorderLayout borderLayout1 = new BorderLayout();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JTextField txtName = new JTextField();

    JPasswordField txtPass = new JPasswordField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    Connection con = null;
    Statement smt = null;
    ResultSet rs = null;

    public Login() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel2.setText("用户名:");
        jLabel2.setBounds(new Rectangle(62, 33, 62, 37));
        jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel3.setText("密码:");
        jLabel3.setBounds(new Rectangle(66, 93, 49, 32));
        txtName.setBounds(new Rectangle(126, 41, 160, 31));
        txtPass.setBounds(new Rectangle(125, 96, 164, 34));
        jButton1.setBounds(new Rectangle(73, 151, 93, 36));
        jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jButton1.setText("登陆");
        jButton1.addActionListener(new Login_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(213, 150, 98, 36));
        jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jButton2.setText("退出");
        this.getContentPane().add(txtPass);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(txtName);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(txtPass);
        this.getContentPane().add(jButton2);
        this.getContentPane().add(jButton1);
    }

    public void jButton1_actionPerformed(ActionEvent actionEvent) {

        if (txtName.getText().trim().equals("")) {
            JOptionPane.showMessageDialog(null, "用户名不能为空!");
        }
        else if (txtPass.getPassword().toString().trim().equals("")) {
            JOptionPane.showMessageDialog(null, "密码不能为空!");
        }


    }
    }


    class Login_jButton1_actionAdapter implements ActionListener {
        private Login adaptee;
        Login_jButton1_actionAdapter(Login adaptee) {
            this.adaptee = adaptee;
        }

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

⌨️ 快捷键说明

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