• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Have a Swing JMenuBar diasppear in the initial frame

 
Stavros Kanarakis
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Let 's suppose that we have an application in which a JFrame appears initially which serves as an input form for the application user.
After the user has completed the form, he submits it and we open a new JFrame which has a JTable inside.

My question is if we can have a JMenuBar that will only be displayed in the second JFrame (after user has submitted on first frame).

I have tried to just create the JMenuBar and put it under the second frame but it is displayed in both frames (initial and JTable).

Please have in mind that once the new frame is opened, the initial one is still open since application assumes that user may choose to close the second frame and re-post things in the form.

Can anyone help me on this?

Thanks
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to just create the JMenuBar and put it under the second frame but it is displayed in both frames (initial and JTable).


Show the code that does that or it didn't happen. A component can have only one parent. If you see a similar menu bar in two frames, then you've created two menu bars.

That said, it's a rare application that benefits from using two JFrames. Much more common is to use a modal JDialog (possibly created and launched using a static method of JOptionPane) for user input.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic