I have a GUI which consists of a toolbar with each button invoking different classes. The class I invoke consist of UI components which are displayed in the Internal frame of the main GUI. The Invoked class works as a separate thread and has to perform the following functions.

  1. Trigger a command to the client, so that the client starts sending the contents of a file.
  2. Receive the file contents here,filter it and add it to a JTable.
  3. Progress bar has to be displayed during the file contents transfer.
  4. Display the UI after adding it to the table.

I am new to Swing worker, so can some one help me to get how it works with my situation and the advantages of using Swing Worker and Invoke later function. I followed the examples in the oracle site and few other sites but I am not able to see how this works for my classes.

有帮助吗?

解决方案

SwingWorker has...

  • Progress change functionality built in, via the PropertyChange support
  • Has helper methods that allow you to synchronise updates to the UI via the publish and process methods, making the process significantly easier...
  • A self contained workflow concept which makes it (generally) easier to use than rolling your own. There are exceptions to the rule, but your outline doesn't fit those exceptions (IMHO) - this is both and advantage and disadvantage...

For example...

One of the (possible) drawbacks to SwingWorker is it will only allow (I believe) 10 workers to be executed simultanously

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top