evandrobm evandrobm - 1 year ago 109
Java Question

Colorize a tab in a JTabbedPane using java swing

I am trying to change the background color of my tabs in a

. I tried
JTabbedPane.setBackgroudAt(0, Color.GRAY)
and the foreground too, but nothing happens. I changed the background of the panel inside the tab, still nothing.

enter image description here

Edit 1: I'm using
if this can help with the solution

Edit 2: Link to a example, https://www.dropbox.com/s/0krn9vikvkq46mz/JavaApplication4.rar

Answer Source
  • most of method for JTabbedPane is protected in the API, and not accesible from Swing methods

  • have to look for Custom XxxTabbedPaneUI, override these methods, and could be accesible from outside

  • correct way would be to implement Custom Look & Feel only, part of them override JTabbedPane

  • example for Custom XxxTabbedPaneUI

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download