File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Handling long running events in the GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Handling long running events in the GUI" Watch "Handling long running events in the GUI" New topic
Author

Handling long running events in the GUI

Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Just wondering how far people went with the GUI when it came to handling long running events? Did you spawn off a separate thread so that the processing was not being carried out on the EDT?

This article here describes the recommended approach for handling processing that may take a long time.

So for example in this assignment things like connect to the database file in standalone mode, connecting the the server in network mode, booking a room, etc.

I guess I should spawn these operations off to a separate thread. But as we know when it comes to threads - the more you have, the more chances for errors!!!


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4913
    
  10

I don't have long running events, so no need to handle them


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Any event that involves network communication can be a long running event as it depends on the network quality. So every solution to this assignment has events that are potentially long running.

When running the client in network mode try entering an incorrect server name/address. Or try connecting when the server is down. Both scenarios will result in an event that does not return instantaneously.

Even in normal usage of your client application in network mode you have the possibility of long running events if there is a poor network connection.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4913
    
  10

Sean Keane wrote:Any event that involves network communication can be a long running event as it depends on the network quality. So every solution to this assignment has events that are potentially long running.

Of course I'm aware of that, just indicating I didn't execute any operation in a seperate thread.

So when you enter some wrong server address, it takes indeed some time and the application freezes for a certain time period.
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Yep, so you had long running events, but executed them on the EDT rather than choosing to spawn them off to separate threads.

Obviously the examiners are not too bothered about this based on your score

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling long running events in the GUI
 
Similar Threads
jess!
Many (really many) tasks in Swing thread
Simple Message that doesn't require response from User?
Command Link, launch a long proccess
Is It good to have thread under a servlet