// ERROR: Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { showHelloThereDialog(); } public void showHelloThereDialog() { Runnable showModalDialog = new Runnable() { public void run() { try{ wait(500); jLabel1.setText("safsadfsdf"); } catch(InterruptedException e){ System.out.println("Sleep Interrupted"); } } }; try { SwingUtilities.invokeAndWait (showModalDialog); } catch(InvocationTargetException e){ System.out.println("Sleep Interrupted"); } catch(InterruptedException e){ System.out.println("Sleep Interrupted"); } }