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

📄 loginview.java~73~

📁 用java写的仓库管理
💻 JAVA~73~
字号:
package cangku;

import java.awt.BorderLayout;
import java.awt.Frame;

import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import javax.swing.ImageIcon;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;
import java.awt.Font;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

public class LoginView extends JDialog {
    LoginHandler lh=new LoginHandler(this);
    JLabel lblLogin = new JLabel(new ImageIcon("image/li.jpg"));
    JLabel lblName = new JLabel();
    JLabel lblpwd = new JLabel();
    JTextField txtName = new JTextField();
    JButton btnenter = new JButton(new ImageIcon("image/yes.jpg"));
    JButton btnexit = new JButton(new ImageIcon("image/exit.jpg"));
    JPasswordField txtpwd = new JPasswordField();
    TitledBorder titledBorder1 = new TitledBorder("");
    TitledBorder titledBorder2 = new TitledBorder("");
    TitledBorder titledBorder3 = new TitledBorder("");
    TitledBorder titledBorder4 = new TitledBorder("");
    JLabel lblbiao = new JLabel();
    TitledBorder titledBorder5 = new TitledBorder("");
    JButton btnanniao = new JButton();
    public LoginView(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public LoginView() {
        this(new Frame(), "系统登录", false);
    }

    private void jbInit() throws Exception {
        lblLogin.setBackground(SystemColor.inactiveCaptionText);
        lblLogin.setPreferredSize(new Dimension(123, 95));
        this.getContentPane().setLayout(null);
        lblLogin.setText("");
        lblLogin.setBounds(new Rectangle(10, 20, 75, 70));
        this.getContentPane().setBackground(UIManager.getColor(
                "Label.background"));
        this.setForeground(Color.lightGray);
        lblName.setBackground(Color.black);
        lblName.setFont(new java.awt.Font("宋体", Font.BOLD, 13));
        lblName.setForeground(Color.blue);
        txtName.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        txtName.setBorder(BorderFactory.createLoweredBevelBorder());
        txtName.setText("");
        txtName.setBounds(new Rectangle(191, 26, 110, 25));
        txtName.addFocusListener(new LoginView_txtName_focusAdapter(this));
        lblpwd.setFont(new java.awt.Font("宋体", Font.BOLD, 13));
        lblpwd.setForeground(Color.blue);
        lblpwd.setText("操作员密码:");
        lblpwd.setBounds(new Rectangle(103, 63, 84, 24));
        btnenter.setBounds(new Rectangle(73, 109, 79, 22));
        btnenter.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        btnenter.setBorder(BorderFactory.createRaisedBevelBorder());
        btnenter.setPreferredSize(new Dimension(79, 22));
        btnenter.setText("");
        btnenter.setActionCommand("enter");
        btnenter.addActionListener(lh);
        btnexit.setBounds(new Rectangle(179, 109, 79, 23));
        btnexit.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        btnexit.setBorder(BorderFactory.createRaisedBevelBorder());
        btnexit.setPreferredSize(new Dimension(79, 23));
        btnexit.setText("");
        btnexit.setActionCommand("Exit");
        btnexit.addActionListener(lh);
        txtpwd.setBorder(BorderFactory.createLoweredBevelBorder());
        txtpwd.setText("");
        txtpwd.setBounds(new Rectangle(191, 63, 110, 25));
        lblbiao.setForeground(Color.red);
        lblbiao.setText("");
        lblbiao.setBounds(new Rectangle(192, 89, 108, 19));
        btnanniao.setBounds(new Rectangle(118, 92, 41, 14));
        btnanniao.setPreferredSize(new Dimension(70, 15));
        btnanniao.addActionListener(new LoginView_btnanniao_actionAdapter(this));
        this.getContentPane().add(txtName);
        this.getContentPane().add(lblName);
        this.getContentPane().add(lblpwd);
        this.getContentPane().add(txtpwd);
        this.getContentPane().add(lblLogin);
        this.getContentPane().add(btnexit);
        this.getContentPane().add(btnenter);
        this.getContentPane().add(lblbiao);
        this.getContentPane().add(btnanniao);
        lblName.setText("操作员名称:");
        lblName.setBounds(new Rectangle(102, 26, 86, 20));
    }

    public void txtName_focusGained(FocusEvent e) {
        lblbiao.setText("");
        txtName.setText("");
    }

    public void btnanniao_actionPerformed(ActionEvent e) {
        Runtime aa=Runtime.getRuntime();
        try {
            aa.exec("C:\\WINDOWS\\system32\\osk.exe");
        } catch (IOException ex) {
        }
    }
}


class LoginView_btnanniao_actionAdapter implements ActionListener {
    private LoginView adaptee;
    LoginView_btnanniao_actionAdapter(LoginView adaptee) {
        this.adaptee = adaptee;
    }

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


class LoginView_txtName_focusAdapter extends FocusAdapter {
    private LoginView adaptee;
    LoginView_txtName_focusAdapter(LoginView adaptee) {
        this.adaptee = adaptee;
    }

    public void focusGained(FocusEvent e) {
        adaptee.txtName_focusGained(e);
    }
}

⌨️ 快捷键说明

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