File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Modal revisited Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Modal revisited" Watch "Modal revisited" New topic

Modal revisited

abid ghani

Joined: Nov 06, 2001
Posts: 3
I have searched the previous topics on Modal and have not found a satisfactory answer to my problem, someone else asked a similar question but was refused an answer because their user name was in an incorrect format. So I have been forced to register and ask the question myself, here it is...
I have a JApplet, I want a JDialog window to appear on top of the applet and become Modal, blocking input to the applet. The problem is the JDialog window does not stay within the bounds of the Applet Frame, it has the ability to go anywhere on screen, how can I restrict it to the Applet Frame? Before you say 'Ahhhhh, try the constructor which asks for: JDialog(Frame owner, boolean)'
too late, i have tried it, it doesn't work.
The JDialog window will not restrict to the applet, any other bright ideas?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

OK... you're asking two different things... making a JDialog modal does not restrict it to the frame that contains it... it just blocks all input to that frame until the JDialog is closed.

Here's one way to do what you're talking about though...

This code works in appletviewer, at least... It partially works in the browser. It is modal to the applet, but does not stay within the bounds. ( I think this is because appletviewer is a Java frame and is able to supply bounds information, whereas the browser frame is not. ) If the bounds control is really important, you can do something like this...

Hope this helps you out...

JavaRanch - Membership has it's privilages...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
abid ghani

Joined: Nov 06, 2001
Posts: 3
Thanks Nathan, I will give it a try and let you know how I get on.
I agree. Here's the link:
subject: Modal revisited
jQuery in Action, 3rd edition