Swing Application Hangs when minimized

We have a Desktop application written in swing which basically uses JGO (www.nwoods.com/go/jgo.html) objects for making test scripts visually which are then used for testing mobiles. We are using Java 5 but in recent days we are experiencing a strange problem. When we have a script which takes more than 10 minutes to run, if we run the script and minimize the application and dont do anything on the machine, the application hangs. We can forcefully maximize the application by using the Windows Task Manager but that it. The application is stuck doing nothing and no response. It is possible that we might have this bug in our previous releases but this has been reported recently by Google (one of our valued customers).

Anyone else has encountered the same issue? Any suggestinos or advice is welcome.

Just to add I figured out the issue. Actaully we show a Modal Dialog box showing the results of the script run to user. Now when the application is minimized this dialog gets lost altough we have set the references to the parent window correctly but some how it nevers hows up. Since the dialog box is modal the user gets the impression that the application is hung but thats no the case. If u just hit the Esc key (same as cacnelling the dialog) everything works smoothly.

I fixed up the issue by putting in a hack; thats all that I could think of that time. I checked the application state before showing the dialog if it was minimized then I added in the dialog showing task to a TaskQueue utilizing the command pattern. As soon as the application was maximized I ran through all the pending tasks in the TaskQueue and then Modal Dialog was shown, resolving the issue.

If anyone is need of the code snippet please letr me know I will add it up here.

Swing Application Hangs when minimized

5 thoughts on “Swing Application Hangs when minimized

  1. Min Idzelis says:

    I think if you minimize an app windows automatically pages out the app’s memory to disk. This is probably causing lots of page faults slowing down your app. Not sure how to get around it. Maybe try launching with javaw.exe? Not sure if it has anything to do with it, but I think there’s an option also to optimize windows for “background services” too which *might* disable that behavior.

  2. Asd says:

    Sounds like you are running your script in the Event Dispatch thread. Go read some basic Swing books and tutorials.

  3. Faisal Feroz says:

    Asd: Well I was thinking the same but we aren’t in the Event Dispatch Thread. A seperate thread is running the script which has callbacks which updates the UI so that a visual notification is given by hughlighting the node we are currently executing 🙂

  4. Faisal Feroz says:

    I found the root cause. At the end of execution we display a modal dialog which shows the results of execution wether it was a success or a failure. When the application was mminimized and this dialog appeared upon maximizing the application forcefully thayt modal dialog never showed up this causing the application not to respond to any events. Even changing the dialog to modeless didn’t solved the problem.

    I think this might be because of the improper parent assigned to the dialog, anyways i changed the dialog to modeless and called centerInWindow to display the dialog when application was maximized.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s