栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

震惊!舍友点了这个题库居然弹了10000个窗?

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

震惊!舍友点了这个题库居然弹了10000个窗?

这个程序是用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);
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/327861.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号