int h = calendar.get(Calendar.HOUR_OF_DAY); int m = calendar.get(Calendar.MINUTE); setText((h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m);
final int h = calendar.get(Calendar.HOUR_OF_DAY); final int m = calendar.get(Calendar.MINUTE); SwingUtilities.invokeLater(new Runnable() { public void run() {   setText((h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m); } });
        private void startTimer() {            timer.schedule(task = new TimerTask() {                Calendar calendar = new GregorianCalendar();                public void run() {                    calendar.setTimeInMillis(System.currentTimeMillis());                    int h = calendar.get(Calendar.HOUR_OF_DAY);                    int m = calendar.get(Calendar.MINUTE);                    setText((h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m);                }            }, 0, 60 * 1000);        }