Search code examples
javaswingedt

Can i run 2 GUI actions in the EDT?


In a JDialog, when user clicks a JButton i want to execute 2 GUI actions in the EDT :

  1. Showing another small JDialog with a busy icon in it to tell the user "Please wait while the wrong process ends".
  2. Inserting a big number of records in a JTable.

When i try to execute both actions the "please wait" dialog blocks the inserting process, as expected.

As you see both actions must be done in EDT ... so is there a solution for this ?


Solution

  • No, both actions should not be executed in the EDT.

    Your records should not be inserted in the JTable, but rather in its TableModel, triggering update events. This way, you can easily have the table updated while your dialog is shown.

    Once the table model is updated, fire an event to ensure table is repainted, and it will work.