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

📄 frame1.java~6~

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

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPasswordField;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Frame1 extends JFrame {
    JPanel contentPane;
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JPasswordField jPasswordField1 = new JPasswordField();
    public Frame1() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(null);
        setSize(new Dimension(358, 221));
        setTitle("Frame Title");
        jLabel1.setText("用户名:");
        jLabel1.setBounds(new Rectangle(42, 41, 88, 27));
        jLabel2.setText("密  码:");
        jLabel2.setBounds(new Rectangle(41, 73, 93, 20));
        jTextField1.setBounds(new Rectangle(142, 38, 171, 21));
        jButton1.setBounds(new Rectangle(39, 134, 113, 25));
        jButton1.setMnemonic('A');
        jButton1.setText("确定(A)");
        jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(179, 129, 116, 25));
        jButton2.setMnemonic('C');
        jButton2.setText("取消(C)");
        jPasswordField1.setBounds(new Rectangle(141, 77, 175, 21));
        contentPane.add(jLabel1);
        contentPane.add(jLabel2);
        contentPane.add(jTextField1);
        contentPane.add(jPasswordField1);
        contentPane.add(jButton2);
        contentPane.add(jButton1);
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        String str=jTextField1.getText().trim();
   //     String strpass=jPasswordField1.getText().trim();
           char ch[]=jPasswordField1.getPassword();
           String strpass=new String(ch);
//           if(str.equals("abc")&&strpass.equals("123"))
//           {
//
//           }

    }
}


class Frame1_jButton1_actionAdapter implements ActionListener {
    private Frame1 adaptee;
    Frame1_jButton1_actionAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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