• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Java Tabbed layout

 
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to learn how to use the tabbed panel and have a question about this code.

I would like to use the BorderLayout and place this line of code so that it uses the 4 locations. add(new JLabel("Tab content " + String.valueOf(i)));


 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JTabbedPane is a component whose purpose is to contain several components, of which only one is visible at any time. It has tabs so that you can switch between components.

And so it doesn't use a layout manager.

You can certainly create a JPanel which uses a BorderLayout and so on, like you said. But JTabbedPane has nothing to do with that.

So for the learning process, I would start out by creating a JPanel which uses a BorderLayout. Remember that when you add a component to a JPanel with a BorderLayout, you have to specify which of the five (not four) parts of the layout the component should appear in. There are online tutorials with examples for you to look at.

Then when you have that working, you can extend your code to add it to a JTabbedPane.
 
Roger Wells
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I do this with a CardLayout and get the same results?
 
Paul Clapham
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what "this" means.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!