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

📄 logindialog1.java~1~

📁 JBuilder2006设计的服装进销存管理系统。 只是一个Demo,但帮助文档等一应俱全。 在使用前请先将数据库中的内容加载到SQLServer2000中
💻 JAVA~1~
字号:
package jinxiaocun;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * <p>Title: FirstApp</p>
 *
 * <p>Description: the first App</p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: star</p>
 *
 * @author star
 * @version 1.0
 */
public class LoginDialog extends JFrame {
    public LoginDialog(MainFrame mf) {
        try {
            jbInit();
            this.mf=mf;
            setSize(400, 300);
            this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            this.setVisible(true);

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }


    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel1.setFont(new java.awt.Font("黑体", Font.PLAIN, 30));
        jLabel1.setForeground(Color.red);
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("欢迎登陆系统");
        jLabel1.setBounds(new Rectangle(85, 29, 222, 50));
        userName.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
        userName.setBounds(new Rectangle(156, 97, 139, 31));
        userPSW.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
        userPSW.setBounds(new Rectangle(156, 146, 139, 31));
        cmdOK.setBounds(new Rectangle(66, 225, 81, 32));
        cmdOK.setText("确定");
        cmdOK.addActionListener(new LoginDialog_cmdOK_actionAdapter(this));
        cmdClean.setBounds(new Rectangle(228, 224, 88, 32));
        cmdClean.setText("重新输入");
        this.getContentPane().add(jLabel1);
        jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel4.setText("密  码");
        jLabel4.setBounds(new Rectangle(65, 146, 73, 31));
        jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel3.setText("用户名");
        jLabel3.setBounds(new Rectangle(65, 97, 73, 31));
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jLabel4);
        this.getContentPane().add(userName);
        this.getContentPane().add(userPSW);
        this.getContentPane().add(cmdOK);
        this.getContentPane().add(cmdClean);
        jLabel2.setFont(new java.awt.Font("黑体", Font.PLAIN, 30));
        jLabel2.setForeground(Color.green);
        jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel2.setText("欢迎登陆系统");
        jLabel2.setBounds(new Rectangle(85, 30, 222, 50));
    }
    int count = 0;
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JTextArea userName = new JTextArea();
    JPasswordField userPSW = new JPasswordField();
    JButton cmdOK = new JButton();
    JButton cmdClean = new JButton();
    MainFrame mf=null;
    public void cmdOK_actionPerformed(ActionEvent e) {

        String strUserName = userName.getText();
        String strPSW = new String(userPSW.getPassword());

        if (strUserName.equals("star")  && strPSW.equals("123456") ) {
//            JOptionPane.showMessageDialog(null, "恭喜您登陆成功");
 //           new MainFrame();
              mf.initMenu(true);


              this.dispose();
        } else {
            if (++count>=3){
                JOptionPane.showMessageDialog(null, "密码不对,请联系管理员");

            } else {JOptionPane.showMessageDialog(null,"密码错误");
            }
        }
    }
    class LoginDialog_cmdOK_actionAdapter implements ActionListener {
        private LoginDialog adaptee;
        LoginDialog_cmdOK_actionAdapter(LoginDialog adaptee) {
            this.adaptee = adaptee;
        }

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

⌨️ 快捷键说明

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