• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTabbedPane

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!!
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic