aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Multiple equal tabs in jTabbedPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Multiple equal tabs in jTabbedPane" Watch "Multiple equal tabs in jTabbedPane" New topic
Author

Multiple equal tabs in jTabbedPane

Liwuen Chew
Greenhorn

Joined: Mar 11, 2010
Posts: 24
Greetings everyone! I hope someone can help me with this doubt!

I have a jTabbedPane with one tab and several components in it (example: one label and one button). I have a button outside of the jTabbedPane which makes a new tab appear in the jTabbedPane (additional to the existing one)
Is there a way to make the new tab to contain a label and a button like the previous tab? I mean to keep adding tabs to the jTabbedPane and make all this tabs to contain a label and a button?

Thanks!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

You can add any child only once to any parent. However, you can create multiple instances of the child component and add them.

In pseudo code
1) Subclass JPanel
2) Add whatever components required to this panel
3) While creating a new tab, create and use a new instance of this subclassed panel.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Liwuen Chew
Greenhorn

Joined: Mar 11, 2010
Posts: 24
Hey! That works!
Thanks!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

You are Welcome!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple equal tabs in jTabbedPane