aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTabbedPane Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTabbedPane Problem" Watch "JTabbedPane Problem" New topic
Author

JTabbedPane Problem

smitha verghese
Ranch Hand

Joined: Jun 21, 2003
Posts: 42
Hi,
I have a main TabbedPane where i added 3 tabs
A,B,C
Now i need to add a TabbedPane into A?? how do i do it?
Please let me know as soon as possible
Thanks
regards
Smitha
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

When you add a tab ( tabbedPane.addTab(..) ) you have to specify a Component. Just pass that method another JTabbedPane object.


GenRocket - Experts at Building Test Data
smitha verghese
Ranch Hand

Joined: Jun 21, 2003
Posts: 42
JTabbedPane tabbedPane1 = new JTabbedPane();
JTabbedPane motorTab= new JTabbedPane();

MainTab()
{
setLayout(new BorderLayout());
motorTab.addTab("Ascans",new Ascans());
----------------------------------------
----------------------------------------
}
Ascans is a panel
class Ascans extends JPanel{

Ascans()
{
setLayout(new BorderLayout());
setBounds(30, 40,300, 200);
setBackground(Color.blue);
setVisible(true);
}
}

But it doesnt add tabs one after another rather adds one on top of another
how come?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You aren't even doing what I said to do. You asked how to add a JTabbedPane to a Tab on a JTabbedPane. All your code does is instantiate 2 JTabbedPanes(), one of which is never used, and then you put a panel on one of the Tabs.

This is the solution to your original question. Is this not what you want?
 
jQuery in Action, 2nd edition
 
subject: JTabbedPane Problem