private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { startCountdown(); } public void startCountdown() { SwingUtilities.invokeLater(new Runnable() { //Note 1 public void run() { for ( int i = 0; i < 2000; i++ ) { System.out.println( i ); try { wait(100); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }); }