| 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: 4163
|
|
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.
|
 |
 |
|
|
subject: Have a Swing JMenuBar diasppear in the initial frame
|
|
|