销毁主类对象
问题描述:
public void executeRepeat(String s) {
this.move = s;
storeValue = move;
i = Integer.parseInt(move);
timer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
i--;
if(i <= 0) {
move = "" + i;
if (move.trim().equals("0")) {
Thread th = new Thread(new DetectImage());
th.start();
}
timer.stop();
}
jTextField1.setText("" + i);
}
});
timer.start();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
move = jTextField1.getText();
executeRepeat(move);
}
public static int stay = 0;
class DetectImage implements Runnable {
@Override
public void run() {
while (stay < 3) {
try {
stay++;
// few steps for comparison
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(TrafficMainGUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (stay >= 3) {
stay = 0;
String store = storeValue;
TrafficMainGUI traffic = new TrafficMainGUI(store);
traffic.setVisible(true);
}
}
}
我打电话给TrafficMainGUI
这个线程。整个过程进展顺利。 但我正在打开多个框架。我想要处理前一帧。我应该如何实现这一点,因为我不能访问线程类中的主要方法。销毁主类对象
答
Frame[] frames = Frame.getFrames();
它会给你总帧数在应用
可以一直使用相同的帧,或者使用一些听众处置掉旧的框架。 – 2013-03-18 10:19:14
-1。 ** 1。**看起来你可以从你的代码示例中删除一些与这个问题无关的部分(为了便于理解,这是很重要的,因为你没有解释你的代码)。和** 2 **我相信SO上的人应该得到格式合理的代码。 – stakx 2013-03-18 10:23:26