I'm new to this forum so hopefully this is the right place to put this question.
I have a relatively simple GUI application written in Java 6u20 that involves a main gui window (extends JFrame). Most of the file menu operations result in a modal dialog (either JFileChooser or JOptionPane) being presented to the user.
The problem is that when running on Unix (HPUX), the process of changing focus to one of these modal dialogs occasionally results in a quick flash of the background terminal window (not necessarily that used to launch the Java), and the process of closing the modal dialogs (by any means, i.e. any dialog button or hitting esc) doesn't always return focus to the main extended JFrame object, sometimes it goes to the terminal window and sometimes just flashes the terminal window before returning to the main JFrame window.
I think the problem is with the Unix window manager deciding that the main focus should be a terminal window, not my Java application, since the problem occurs in both directions (i.e. focus from main JFrame to modal dialog or vice versa).
In most cases of JOptionPane, I DO specify that the main extended JFrame object is the parent.
I've tried multiple things, including calling the following methods:
just before and after dialog display, and following selection of any button from the dialogs. This reduced frequency of the problem, but it always tends to flash the terminal window if not return focus to it completely.
Any help appreciated thanks,
Self-contained compilable example below, but note that the problem doesn't occur running on Windows (XP) and that my actual program doesn't use auto-generated code generated by a guibuilder:
This may not be a Java problem but a window manager problem. If that's the case you may not be able to solve it.
One annoyance I have in Windows is that when a non-active Java program shows a dialog (like a progress dialog or something) then this dialog will become the active window. I haven't been able to solve this either, since it's a Windows issue.
My gut feeling is that it's a Unix windows manager problem, in which case does anyone know any options that can be set in Unix to change what priority/scope a program is given?
posted 10 years ago
Thanks all for your prompt replies and help!
After reading the 6262392 bug, I decided to re-write in java version 5 (luckily all I had to change was the LayoutManager), and the problem doesn't seem to be there any more.
Incidentally, my html-formatted message dialogs now include ">" characters at every newline (I used <br />); I assume this is because the html version is different or something, so I'll experiment to find something that works!
Simon George wrote:Incidentally, my html-formatted message dialogs now include ">" characters at every newline (I used <br />); I assume this is because the html version is different or something, so I'll experiment to find something that works!
I think you're not supposed to terminate the BR like you're doing. Just use <br> and see if that works.
Those are the largest trousers in the world! Especially when next to this ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop