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 JDialog &Modal.  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog &Modal.  " Watch "JDialog &Modal.  " New topic
Author

JDialog &Modal.

Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
I made my JDialog modal, but if I click on the JFrame that loaded the JDialog, the JDialog will still sit behind the JFrame, and the JFrame will be disabled. I guess this is the difference between a modal frame in Java, and VB.
How do I make this JDialog stay on the very front of the screen until it is closed? I was thinking of locking the mouse inside the frame so it can't move out but thats a little too forceful. Any help would be great thanks!
By the way, I'm using VisualAge for Java, and there is an option to make the JDialog modal, as well as the Bean that I place within the main frame. --i know this isn't a VisualAge discussion but....just in case that helps anyone out!
[ August 17, 2002: Message edited by: Brett Swift ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

http://java.sun.com/j2se/1.4/docs/api/javax/swing/JDialog.html
It often helps to read the API.
JDialog(Frame owner, String title, boolean modal)
Creates a modal or non-modal dialog with the specified title and the specified owner Frame.
"...I guess this is the difference between a modal frame in Java, and VB."
Is it? What is the difference? Oh, that VB doesn't give you the option for the Frame owner? Hmm, sounds like a limitation to me.


GenRocket - Experts at Building Test Data
Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
well thanks for the help bud..of course I read the API though! thats what I'm confused about.
in the creation of the frame, i have the line:
setModal(true);
..this locks up the parent frame..but you can still hide the modal dialog box.... when you click outside on the main application, this dialog still disappears behind the main application, and you have to minimize the application to find the JDialog, because it doesn't appear on the task manager.
thanks for your input though.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

You still haven't specified the parent frame that the Dialog should be modal to. That is why it can go behind your frame. If you set the frame owner, it will stay in front of that frame like you want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDialog &Modal.