• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTabbedPane - different color per selected tab  RSS feed

 
William Spear
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a JTabbedPane with tabs that will have different colors when selected. For example, let's say I have tabs A, B, and C. If a tab is not selected, then the tab color will be the default. If tab A is selected, then the tab color will change to red. If tab B is selected, then the tab color will change to green. If tab C is selected, then the tab color will change to yellow. How can I achieve this behavior? The closest method I could find was calling UIManager.put("TabbedPane.selected", Color.RED) but this sets the color of all selected tabs to red.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Try JTabbedPane#setBackgroundAt(int index, Color background) combined with addChangeListener
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!