SwingWorker, if only done (), does not require doInBackground (), that is, do not need to do anything in another thread . Then I ( ) wrote in doInBackground return null; it is to be used by another thread to perform this sentence, although the only one . How to completely do not use another thread ?
I want to use javax.swing.SwingWorker class to write done () inside the operation is relatively simple to write a number of specifications , such as using javax.swing.SwingWorker characteristics executed only once , or else have to write their own control code, although the writing is not complicated .
------ Solution ---------------------------------------- ----
point if the button down, the event is being executed , the EDT is occupied, this time " and click on a " click event will be discharged into the queue , etc. The event is executed after the completion of re- executed.
The short answer is : will perform twice.
not to deal with the demand to see the operation if the button is obviously time consuming event is raised , it may not be a good design directly in ui thread, because users see after the button is pressed on the screen does not move stuck .
------ For reference only -------------------------------------- -
not understand your needs.
current thread is EDT, when the target is called to be performed in the EDT :
synchronous call , you can call directly .
asynchronous call , you can use SwingUtilities.invokeLater (Runnable)
If you do not need to run a background thread stuff , do not use SwingWorker.
------ For reference only -------------------------------------- -
+1, new Thread () ....
------ For reference only ------------------ ---------------------
+1, New Thread () ....
If the button points down, is running the event , not playing up, and click once, will perform twice? Do you want to add some measures, such as buttons setennable = false
------ For reference only ---------------------------- -----------
http://blog.csdn.net/raistlic/article/details/17375319
------ For reference only ------- --------------------------------
point if the button down, the event is being executed , the EDT is occupied, this time " and click on a " click event will be discharged into the queue , etc. The event is executed after the completion of re- executed.
The short answer is : will perform twice.
not to deal with the demand to see the operation if the button is obviously time consuming event is raised , it may not be a good design directly in ui thread, because users see after the button is pressed on the screen does not move stuck . Thank you .
没有评论:
发表评论