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

📄 landing.java

📁 包括源代码
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package testgui;import DBOperation.DBUser;import java.awt.*;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.*;import java.awt.event.*;import java.io.*;/** * * @author RJ-408 */public class Landing extends JFrame implements ActionListener {        JLabel 用户名,密码;    JTextField 用户名1;    JPasswordField 密码1;    JButton 登录,取消,注册;    LandFalse falseMessage;    RagisterMessage message;    UserTest usertest;        public Landing()    {        super("用户登录");        this.setLayout(null);                用户名=new JLabel("用户名");        密码=new JLabel("密   码");                用户名1=new JTextField(10);        密码1=new JPasswordField(10);                登录=new JButton("登录");        注册=new JButton("注册");        取消=new JButton("退出");                登录.addActionListener(this);        注册.addActionListener(this);        取消.addActionListener(this);                用户名.setBounds(10, 10, 80, 20);        密码.setBounds(10, 30, 80, 20);        用户名1.setBounds(90, 10, 150, 20);        密码1.setBounds(90, 30, 150, 20);        登录.setBounds(10, 60, 80, 20);        注册.setBounds(100, 60, 80, 20);        取消.setBounds(190, 60, 80, 20);                this.add(用户名);        this.add(密码);        this.add(用户名1);        this.add(密码1);        this.add(登录);        this.add(注册);        this.add(取消);                this.setBounds(200, 200, 290, 120);        this.setVisible(true);    }    public void actionPerformed(ActionEvent e) {        if(e.getSource()==登录)        {            DBUser user = new DBUser();            try {                int j[] = user.UserLand(用户名1.getText(),this.toString(密码1.getPassword()));                if (j[0]==1&&j[1]==2) {                    JFrame.setDefaultLookAndFeelDecorated(true);                    JFrame frame=new JFrame("用户测试");                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                    usertest=new UserTest();                    usertest.setOpaque(true);                    frame.setContentPane(usertest);                    frame.pack();                    frame.setVisible(true);                    //usertest=new UserTest("用户测试");                    usertest.删除用户.setEnabled(false);                    usertest.添加用户.setEnabled(false);                    usertest.用户权限.setEnabled(false);                    usertest.插入题目.setEnabled(false);                    usertest.删除题目.setEnabled(false);                      usertest.setVisible(true);                    this.setVisible(false);                }                 else if(j[0]==1&&j[1]==1)                {                    JFrame.setDefaultLookAndFeelDecorated(true);                    JFrame frame=new JFrame("用户测试");                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                    usertest=new UserTest();                    usertest.setOpaque(true);                    frame.setContentPane(usertest);                    frame.pack();                    frame.setVisible(true);                   // usertest=new UserTest("用户测试");                    usertest.setVisible(true);                    this.setVisible(false);                }                else {                    falseMessage=new LandFalse(this);                    falseMessage.setVisible(true);                }            } catch (Exception ex) {                Logger.getLogger(Landing.class.getName()).log(Level.SEVERE, null, ex);            }        }        if(e.getSource()==注册)        {            message=new RagisterMessage(this);            message.setVisible(true);           }        if(e.getSource()==取消)            System.exit(0);//        throw new UnsupportedOperationException("Not supported yet.");    }        public String toString(char[] p)    {        String password="";        char pass[]=p;        for(int i=0;i<pass.length;i++)            password=password+pass[i];        return password;    }        public static void main(String args[])    {        Landing land=new Landing();    }}

⌨️ 快捷键说明

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