• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pop up a JFrame on top of another JFrame ?  RSS feed

 
Mxolisi Veco
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!