900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > java点击按钮弹出警告_GUI求教~~~我想点击按钮确定后 弹出一个提示框输入有误! …...

java点击按钮弹出警告_GUI求教~~~我想点击按钮确定后 弹出一个提示框输入有误! …...

时间:2020-10-30 15:35:20

相关推荐

java点击按钮弹出警告_GUI求教~~~我想点击按钮确定后 弹出一个提示框输入有误!  …...

该楼层疑似违规已被系统折叠隐藏此楼查看此楼

靠 看错题目了

是这样才对

import java.awt.EventQueue;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import javax.swing.JButton;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent; public class Test02 extends JFrame { private JPanel contentPane; public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

Test02 frame = new Test02();

frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

} public Test02() {

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100, 100, 450, 300);

contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);

contentPane.setLayout(null); JButton button1 = new JButton("button");

button1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

new Thread() {

public void run() {

try {

Thread.sleep(2000);

}

catch (InterruptedException e) {

}

JOptionPane.getRootFrame().dispose();

}

}.start();

JOptionPane.showMessageDialog(null, "输入有误");

}

});

button1.setBounds(172, 115, 87, 23);

contentPane.add(button1);

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。