aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Have a Swing JMenuBar diasppear in the initial frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Have a Swing JMenuBar diasppear in the initial frame" Watch "Have a Swing JMenuBar diasppear in the initial frame" New topic
Author

Have a Swing JMenuBar diasppear in the initial frame

Stavros Kanarakis
Greenhorn

Joined: Sep 28, 2010
Posts: 12
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

Exploring Java world...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Have a Swing JMenuBar diasppear in the initial frame