| Author |
How to pop up a JFrame on top of another JFrame ?
|
Mxolisi Veco
Ranch Hand
Joined: Jan 14, 2010
Posts: 59
|
|
Hi everyone.
I have two JFrames, FrameA and FrameB. I want to make the other FrameB to pop up infront of FrameA such that the user will not be able to click on FrameA.
What I do currently I disable FrameA when a user takes some action, the only way to enable FrameA is to close FrameB.
My problem is that a user can still click on FrameA even though nothing happens until the user closes FrameB.
I want my FrameB to pop up like a JOptionPane Message Dialog, right at the center of FrameA and to force users to close FrameB before they can click on FrameA.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8436
|
|
|
Why not use JOptionPane itself? The showXXXDialog accepts objects as messages. You can get the content pane's contents of frame B, pass it as message to the JOptionPane and call the required showXXX method.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Change FrameB into a modal JDialog. You shouldn't change anything except for the class you extend and the constructor; JFrame and JDialog are very much alike.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: How to pop up a JFrame on top of another JFrame ?
|
|
|