This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hi All, I m making an application in swings using JInternalFrames. I would like My JInternalFrame to be Modal so that Unless it is closed nobody can alter components to the back of this Internal Frame any help will be hishly appreciated
Top level containers like JFrame are composed of several panes: the root pane, the content pane and the glass pane. JInternalFrames usually sit on the content pane or some layer between it and the glass pane. To make a JInternalFrame "modal", that is, block input to other frames below it, add it to the glass pane (there's a JFrame.getGlassPane() method), set the glass pane to be visible (glasspane.setVisible(true)) and add a bogus mouse listener to the glass pane to block input to anything but your "modal" frame (i.e glasspane.addMouseListener( new MouseAdapter())). To remove the modal dialog, remove the frame from the glass pane, set the pane to be invisible and remove the listener. For a high-level discussion of JFrame, seeThe Java Tutorial: Using Top-Level Containers
I know its an ancient thread, but I followed the advice in this topic and I have encountered a serious problem.
After resizing JInternalFrame the glass pane disappears! Frame still sits on it but it looks like some event sets visibility of the glass pane to false. What's going on?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
same advice you were given at stackOverflow applies here
i.e. prove it
OK, I've submitted code sample to StackOverflow. So I maybe post it here too:
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
don't know why it does that, but this hack might be enough to get you around it
Mark Malkiewicz
Greenhorn
Joined: Feb 16, 2013
Posts: 5
posted
0
Thank you very much, It works!
However there is another issue. When I use "Motif" Look&Feel I can't close JInternalFrame. That theme does not show the close button. You have to click the button on the right then menu pops-out and there is an option to close the internal frame. Sadly It can't be clicked (I think menu opens not in a glass pane). How can I fix that?
Here is the screen-shot:
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
found this via google
Bug Alert! The Motif L&F does not supply proper resources for JInternalFrame rendering.
A quick look at the MotifLookAndFeel source code shows that no resources are placed in the defaults table corresponding to JInternalFrame.
This is why the appearance of InnerFrame is not at all consistent with JInternalFrame under the Motif L&F.
(This is actually more of a design flaw than a bug.)
the popup (with close) does seem to be under the glasspane.
as this is likely to be system generated, access (for modification) would be difficult.
perhaps the easiest way is to make the internal frame iconifiable
when iconified, you can left-click the icon and the same popup is now clickable