java - Destroying main class object -


public void executerepeat(string s) {     this.move = s;     storevalue = move;     = 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 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);         }     } } 

i calling trafficmaingui class thread. whole process going smoothly. getting multiple frames opened. want previous frames dispose. how should achieve here because cannot access main method dispose in thread class.

frame[] frames = frame.getframes();   

it give total frames in application


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -