wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes JDialog in front when JFrame on top? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog in front when JFrame on top?" Watch "JDialog in front when JFrame on top?" New topic

JDialog in front when JFrame on top?

Tom Rodrigo

Joined: Dec 07, 2001
Posts: 26
Hi all,
In my (one and only) JFrame it is possible to call up several JDialogs, only one or two at a time. These jdialogs are setModal(true). Now, everything works fine, but when I start another program, i.e. Windows Explorer, and I want to move back to my little application via the windows-taskbar, it's only possible to view the jframe, but not an (open) jdialog. I can only switch to the open dialog via Alt + Tabulator.
How can I automatically switch to an open JDialog whenever the JFrame is in front of the screen?
I've heard that maybe I should replace the dialogs by frames but I don't want to fill the windows-taskbar with more than one 'button' for the same application...
Any ideas?
Thanks in advance!
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Are you passing the parent component (your JFrame) to the JDialog constructor? If so, then the dialog will always be on top of the JFrame. If you don't, then you'll have a modal dialog that's drawn behind your JFrame when you click back on the application.
I don't know of any way in java to add a JDialog to the task bar.

SCJP 1.4
Tom Rodrigo

Joined: Dec 07, 2001
Posts: 26
Hey Rob,
you did it!
It took me some work to pass the JFrame to the JDialog constructor, but it works fine now...
Thanks for you help!
I agree. Here's the link: http://aspose.com/file-tools
subject: JDialog in front when JFrame on top?
Similar Threads
Problem reactivating JDialogs
Multiple JFrames but no desktop no JDesktopPane
JFrame & FocusListener
Mac Java runtime, JDialog getting stuck behind parent JDialog
JDialog questions