zoukankan      html  css  js  c++  java
  • JAVA第二次作业

    源代码:

    package hjhjh;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class LoginWindow extends JFrame implements ActionListener,ItemListener
    {
    JLabel user=new JLabel("用 户 名:");
    JLabel password=new JLabel("密 码:");
    JLabel usertype=new JLabel("用户类型:");
    JButton login=new JButton("登陆");
    JButton cancel=new JButton("取消");
    ButtonGroup buttongroup=new ButtonGroup();
    JRadioButton manager=new JRadioButton("管理员");
    JRadioButton normaluser=new JRadioButton("普通用户");
    JTextField text1=new JTextField(18);
    JPasswordField text2=new JPasswordField(18);
    public LoginWindow()
    {
    super("登陆窗口");
    setSize(300,200);
    setVisible(true);
    setResizable(false);
    setLayout(new FlowLayout(FlowLayout.CENTER,15,10));
    add(user);
    add(text1);
    add(password);
    add(text2);
    add(usertype);
    add(manager);
    add(normaluser);
    buttongroup.add(manager);
    buttongroup.add(normaluser);
    add(login);
    add(cancel);
    manager.addItemListener(this);
    normaluser.addItemListener(this);
    login.addActionListener(this);
    cancel.addActionListener(this);
    Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width-300)/2,(screen.height-220)/2);
    addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    dispose();
    System.exit(0);
    }
    });
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==login)
    {
    ;
    }
    else if(e.getSource()==cancel)
    {
    dispose();
    System.exit(0);
    }
    }
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getSource()==manager)
    {
    ;
    }
    else if(e.getSource()==normaluser)
    {
    ;
    }
    }
    public static void main(String args[])
    {
    new LoginWindow();
    }
    }
    

      

  • 相关阅读:
    pyhton 163 email ssl attach file
    Database creation error: relation "ir_model" does not exist LINE 1: SELECT * FROM ir_model WHERE state='manual' ^
    爬虫心得
    WSL windows子系统ubuntu18.04建设自己的乌云
    WSL windwos 子系统 ubuntu18.04安装mysql
    python 163 email 554
    自定义的应用层协议(转)
    嵌入式杂谈之文件系统(转)
    linux VFS
    C++之保护和私有构造函数与析构函数
  • 原文地址:https://www.cnblogs.com/lkh960317/p/5304117.html
Copyright © 2011-2022 走看看