【发布时间】:2015-12-02 11:38:29
【问题描述】:
我使用下面的代码每 x 次打开一个第 1 帧,但是当我转到另一个帧并返回时,计时器会自行重置,从而导致第二个第 1 帧出现
这是有问题的,因为我一次只需要 1 个尝试使用 isvisbile() 但也没有用。
代码如下:
int timerTimeInMilliSeconds2 = 30000;
javax.swing.Timer timer2 = new javax.swing.Timer(timerTimeInMilliSeconds2, new ActionListener() {
public void actionPerformed(ActionEvent e) {
Pop p=new Pop();
p.setVisible(true);
new Thread(){
@Override
public void run() {
try {
Thread.sleep(5000); // time after which pop up will be disappeared.
p.dispose();
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
}
});
timer2.start();
【问题讨论】:
-
你的问题行“倒计时重置它自己导致第二帧 1 显示希望是象征性的”有点不清楚。您能否对此提供更多解释以更好地理解您的问题?
-
frame-1 是弹出窗口,frame-0 是我的主要窗口-x 计时器重置并导致弹出多个 frame-1 提前谢谢你
标签: java multithreading timer