File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Focus on JDialog lost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Focus on JDialog lost" Watch "Focus on JDialog lost" New topic
Author

Focus on JDialog lost

Frank Thompson
Greenhorn

Joined: Dec 17, 2003
Posts: 2
Hi, I am having a problem to keep the focus on a JDialog and I hope someone could help me.
My application opens a form in a JDialog, but whenever the user clicks outside the application in another program, and go back to the application using the Windows task bar, I can only see the application(on which I cannot interract), not the JDialog.
I am using the following constructor for my JDialog:
public Employe(Frame owner, String title, boolean modal, int noEmploye) {
super(owner,title,modal);
setResizable(false);
setNoEmploye(noEmploye);
refresh();
setVisible(true);
}
And I call it using:
Employe emp = new Employe(this,"",true,noEmploye);
Am I doing something wrong? If not, how do I ensure my JDialog will keep the focus when changing applications?
Thank you very much!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

I think your expectations for a modal dialog are a little high. A modal dialog will only block input to its owner frame. It won't block access to other applications.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Frank Thompson
Greenhorn

Joined: Dec 17, 2003
Posts: 2
Hi, thanks for the answer. Maybe I wasn't clear, I don't mean to prevent the user to go to other applications, but rather that when the user comes back to my application, that the Dialog be on top instead of the owner frame.
I hope this is clearer
Thanks in advance!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

It really *should* be working if you are passing in the owner correctly. Is something happening like your current class extends JFrame, but the actual visible JFrame is another JFrame instance?

You can also try out the code below and see the differences between launching a dialog using the actual parent frame and other references. Just to make sure there are no OS, JDK version, etc. problems...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Focus on JDialog lost
 
Similar Threads
modal in JDK 1.3
Modal JWindow
urgent please help
modeless dialogs in swing
Modal JWindow