Java event queue event events flush / trap events

I have a design-related question I'm trying to find the answer to.

Here is the script.

Suppose you want to do something expensive (time-consuming) as a result of user input (for example, loading huge data from some database, reading large files). It is highly recommended that you use time-consuming work in a separate thread and never block EDT, otherwise the GUI will not respond.

However, there are scenarios where you do not have to enter data into the graphical interface if the background task is not completed. In my particular case, only after the background has finished, can I determine which GUI elements should be visible and enable / disable. Only those GUI elements that should be visible and enabled should respond to user inputs, otherwise the behavior may be unpredictable in my particular case.

This is what I do to deal with such a scenario.

Step 1: Before I begin to do a lot of time.

  • Change the cursor to the loaded cursor.
  • Add the mouse to the glass panel of the frame of the top level component.
  • Make the glass panel visible so that it can receive mouse events. Glass panels do nothing due to mouse inputs.

2: . finally, , ( - ).

3:

  • .
  • .
  • , .

?

, , ?

+3
1

SwingWorker . , done(). run "" "".

: back-port Java 1.5 .

+5

All Articles