Hi all,
Although my application already works fine, after reading some discussions on this form I am wondering if my GUI will pass the critics...
For the custom actions ((dis)connecting, booking, searching), I use Swing actions in which the actionPerformed method calls an operation on the Controller.
If the Controller operation succeeds, it calls notifyObservers on the model. And as the View is registered as an observer of the Model, the update() method on the View is called, which refreshes the View.
So far so good. But we are talking here about synchronous invocation of Controller operations. If an operation takes a longer time (as we may expect of all remote calls), the EventDispatchThread handling the actionPerformed method will spent too much time executing our action, resulting in freezing of the GUI.
We may wonder whether this is a problem, or if Sun expects us to address this pretty advanced item...
Some on this forum, however, have the opinion that all potentially longer Swing operations should be called asynchronously by spawning a separate
thread. And maybe they are right.... !?
Suppose we do so. In my experimental code, I have implemented the actionPerformed method in my FbnAbstractAction class as follows:
and the callAsynchronousTask() method is of course implemented in the concrete XxxxxAction classes.
This works, but how about updating the GUI ? This happens now inside the controller methods called by the concrete implementation of callAsynchronousTask.
So:
-Is is a good idea to use asynchronous execution of Swing actions ?
-Should we use invokeLater to update the Gui ?
-If so, can we still update the Gui by calling update() from the Model ? Or do we need to perform the update inside the Swing actions ?
-Isn't it better to just let the GUI freeze shile executing an action ? None of the actions (connecting, searching, booking...) will ever be executed concurrently by one client.
This is my last big issue prior to submitment. But a iam afraid to lose main point (or fail !) by not handling Swing-multithreading correctly.
Please who can make thing a bit more clear... ?
Regards, Klaas
[ September 30, 2004: Message edited by: Klaas van Gelder ]
[ September 30, 2004: Message edited by: Klaas van Gelder ]