Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTabbedPane Problem

 
smitha verghese
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add a tab ( tabbedPane.addTab(..) ) you have to specify a Component. Just pass that method another JTabbedPane object.
 
smitha verghese
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic