public void showNotify() { super.showNotify(); timer = new Timer(); TimerTask ui = new TimerTask() { public void run() { render(); flushGraphics(); } }; timer.schedule(ui, 0, UI_PERIOD); TimerTask logic = new TimerTask() { public void run() { logic(); } }; timer.schedule(logic, 0, LOGIC_PERIOD); }
public void hideNotify() { super.hideNotify(); timer.cancel(); }