rodd
rodd

Reputation: 193

Get TabbedPane tab content background color - Java Swing

After some extensive search, I have not been able to figure out how to get the color shown in the image below pointed by the red arrow. The reason I want to get this color value is to set the pane background inside the JTabbedPane (blue arrow) with the same value, so there would be no difference between the two colors. On Windows, the color is white (red arrow), on Mac it's 230, 230, 230 RGB, and on Linux it depends on the GUI. So, by getting this value programatically, I wouldn't have to set it for each OS.

enter image description here

Any idea how to accomplish this? I've tried searching for 230, 230, 230 in UIManager.getDefaults() but there isn't such value.

Thanks in advance

Upvotes: 2

Views: 284

Answers (1)

Guillaume Polet
Guillaume Polet

Reputation: 47608

Consider simply setting the opacity of the contained panel to false. This should let the background color of the wrapping JTabbedPane reflect through that component and achieve the desired behaviour. Moreover this will work on all platforms and look and feels.

Something like:

pane.setOpaque(false);

Upvotes: 2

Related Questions