Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default tab setting in Swing

 
Sharad
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on swing application.

In a panel, there are three tabs and when i am opening a starting my application, by default the 1st tab is displaying...

My requirement is - I need to display 3rd tab as a default , with out changing the order of tab.

Code snippet :-

JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("1st", panel1);
tabbedPane.addTab("2nd", panel2);
tabbedPane.addTab("3rd", panel3);

please let me know how to achieve this.

Thanks in advance
Sharad
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharad Golu:

My requirement is - I need to display 3rd tab as a default , with out changing the order of tab.


Welcome to the ranch Sharad.
Check out JTabbedPane#setSelectedIndex(int index).
You might also want to take a look at this tutirial while you are at it.
 
Sharad
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maneesh.

It is working.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic