关于java JFrame
我想知道当达到某一条件如何弹出警告窗口,然后点击里面的按钮,JFrame就重置为一开始的状态。。。谢谢~...
我想知道
当达到某一条件如何弹出警告窗口,然后点击里面的按钮,
JFrame就重置为一开始的状态。。。
谢谢~ 展开
当达到某一条件如何弹出警告窗口,然后点击里面的按钮,
JFrame就重置为一开始的状态。。。
谢谢~ 展开
1个回答
展开全部
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class F1 extends JFrame implements Runnable {
private boolean runnable = true;
public F1() {
super("测试");
this.setSize(400, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String arg[]) {
new Thread(new F1()).start();
}
public void run() {
while (runnable) {
this.setSize(this.getWidth() + 10, this.getHeight() + 10);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
if (this.getWidth() > 600) {
int i = JOptionPane.showConfirmDialog(this, "要回原来吗?", "友情提示",
JOptionPane.YES_NO_OPTION);
if (i == JOptionPane.OK_OPTION) {
this.runnable = false;
this.setSize(400, 300);
}
}
}
}
}
import javax.swing.JOptionPane;
public class F1 extends JFrame implements Runnable {
private boolean runnable = true;
public F1() {
super("测试");
this.setSize(400, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String arg[]) {
new Thread(new F1()).start();
}
public void run() {
while (runnable) {
this.setSize(this.getWidth() + 10, this.getHeight() + 10);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
if (this.getWidth() > 600) {
int i = JOptionPane.showConfirmDialog(this, "要回原来吗?", "友情提示",
JOptionPane.YES_NO_OPTION);
if (i == JOptionPane.OK_OPTION) {
this.runnable = false;
this.setSize(400, 300);
}
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询