• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTabbedPane

 
Jess Ishasder
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have created a JTabbedPane object. There are two panels on it, tab "Add" and tab "Remove" represent them. I would like to set the background color of tab "Add" to be yellow when the applet is first loaded. Then when one tab is selected(i.e. active), I would like to change its background color to be yellow.
Can any of you teach me how to do that?
Thank you !!!
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I can teach you how to do that.
First: Re-register with a valid user name. Here at the ranch we REQUIRE that the user name be firstName + space + lastName. If you wish to continue posting here change your name soon! The ranch naming policy: http://www.javaranch.com/name.jsp
-----------------------------------------------
To perform the tab coloring you just need to set the color in the UI manager with the following line in your code:
UIManager.put( "TabbedPane.selected", Color.green );
The following example uses it.

Enjoy,
Manfred.
 
Pascal Got
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's great ....
Following the same idea, how can I change the font color ? (if I want to make it bold for example)
Also where can I find the declaration of all those resources like "TabbedPane.selected" ?
Cheers
Pascal
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pascal,
To change the font (size, type, or color) simply add the following lines to the program I already posted:
UIManager.put( "TabbedPane.font", new Font( "Dialog", Font.ITALIC, 24 ) );
UIManager.put( "TabbedPane.foreground", Color.red );
To find out those great UIManager properties you can run the following class.

Regards,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic