/** * constructor * * @param writable boolean */ public ProbeButton(SessionShare sshare, ButtonIF vif, String typ) { super(sshare, vif, typ); setHorizontalTextPosition(CENTER); setVerticalTextPosition(BOTTOM); setState(WRONG_PROBE); setProbeName("probe 3"); probeThread = new Thread(this); probeThread.setName("ProbeButton"); probeThread.start(); } // ProbeButton()
public void quit() { try { probeThread.join(5); } catch (InterruptedException e) { } probeThread = null; }
/** run thread */ public void run() { for (; ; ) { try { Thread.sleep(1000); } catch (InterruptedException e) { } switch (state) { case WRONG_PROBE: if (getIcon() == wrongProbeImage) { setIcon(readyProbeImage); } else { setIcon(wrongProbeImage); } break; case ERROR: if (getIcon() == errorProbeImage) { setIcon(readyProbeImage); } else { setIcon(errorProbeImage); } break; } } // infinite loop } // run()