Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JTabbedPane Problem

 
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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?
 
    Bookmark Topic Watch Topic
  • New Topic