aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to add new tabs from JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add new tabs from JMenu" Watch "How to add new tabs from JMenu" New topic
Author

How to add new tabs from JMenu

Med Shabe
Ranch Hand

Joined: May 08, 2001
Posts: 84
I have a JMenu class (GoofyMenuBar.java) and a JTabbedPane class (LoginTabbedPane.java) that I�m putting into a splitPane (SplitPane.java).

Clicking on the Go button opens a new tab. I need to invoke the same action from the menu but somehow I�m not making the connection between the components.

Regardless of the ugliness, how can I invoke a method on JTabbedPane from the JMenu, and later from the JToolBar. Apparently, simply instantiating the class does not do the trick.

Appreciate the input.


LoginTabbedPane


GoofyMenuBar.java


SplitPane
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you want item1 of the menu to create/add an info page?
(same as clickig the 'Go' button)

if so, follow the changes here, and you should get it to work OK

the main differences are the passing of the LoginTabbedPane reference to the
GoofyMenuBar class, and the creation of a separate method to create/add
the info page - this can then be called by both the Go button and the menu item

note: lots of 'comment-outs', just to get it to compile - I don't have
programix.* stuff, or FormLayout stuff. I put them all in one java file,
but you have 2 x main()

you will probably need to handle a second click on the menu item - do you
want a second info page created/added etc etc



Med Shabe
Ranch Hand

Joined: May 08, 2001
Posts: 84
Thanks Michael.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to add new tabs from JMenu