• java第二次作业


    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;

    public class Test26 {

    public static void main(String[] args) {
    final String userName = "abc";
    final String passwrod = "123";
    JFrame jFrame = new JFrame("登陆界面");
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    jFrame.setBounds(((int)dimension.getWidth() - 200) / 2, ((int)dimension.getHeight() - 300) / 2, 200, 150);
    jFrame.setResizable(false);
    jFrame.setLayout(null);
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label1 = new JLabel("姓名");
    label1.setBounds(10, 10, 100, 30);
    jFrame.add(label1);

    JLabel label2 = new JLabel("密码");
    label2.setBounds(10, 40, 100, 30);
    jFrame.add(label2);

    final JTextField text1 = new JTextField();
    text1.setBounds(50, 15, 130, 20);
    jFrame.add(text1);

    final JPasswordField text2 = new JPasswordField();
    text2.setBounds(50, 45, 130, 20);
    jFrame.add(text2);

    JButton button = new JButton("Login");
    button.setBounds(10, 75, 170, 40);
    button.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
    if(userName.equals(text1.getText()) && passwrod.equals(text2.getText())) {
    JOptionPane.showMessageDialog(null, "登陆成功误", "提示", JOptionPane.INFORMATION_MESSAGE);
    } else {
    JOptionPane.showMessageDialog(null, "错误", "提示", JOptionPane.ERROR_MESSAGE);
    text1.setText("");
    text2.setText("");
    }
    }
    });
    jFrame.add(button);

    jFrame.setVisible(true);
    }

    }

  • 相关阅读:
    UVA 10827 Maximum sum on a torus 最大矩阵和
    UVA 11100 The Trip, 2007 水题一枚
    编程之美2015测试赛 题目1 : 同构
    UVA 10801 Lift Hopping Floyd
    UVA 11389 The Bus Driver Problem 贪心水题
    UVA 11039 Building designing 贪心
    UVA 11636 Hello World! 水题
    poj 3070 Fibonacci 矩阵快速幂
    hdu 1757 A Simple Math Problem 矩阵快速幂
    了解常见的 Azure 灾难
  • 原文地址:https://www.cnblogs.com/nmxz/p/5308096.html
Copyright © 2020-2023  润新知