File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add new tabs from JMenu
 
Similar Threads
JTabbedPane display Problem
JSplitterView treats panes differently
How to change components(JTextField) size dynamic in JTabbedPane?
JTabbedPane problems - not loading correctly
Layout Problems