• 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();
    }
    }
    

      

  • 相关阅读:
    show parameters和强制索引失效
    ALTER INDEX 始末
    ADMIN OPTION和GRANT ANY OBJECT PRIVILEGE的问题
    oracle正则表达式函数简单总结(一)
    简单说一下Native Dynamic SQL(动态sql)和包DBMS_SQL
    金山快盘的文件上传
    桶中取黑白球问题
    读书笔记:编程之美求二进制数中1的个数
    vim配置文件.vimrc
    JVM内存管理
  • 原文地址:https://www.cnblogs.com/lkh960317/p/5304117.html
Copyright © 2020-2023  润新知