user1289877
user1289877

Reputation: 279

Replace tab with icon in JTabbedPane

Can someone give me advice on how can I the change tab (only in the tab itself, not the tab's content area) in JTabbedPane to an icon. It is possible to set another icon when the tab is selected, another icon on mouse over, and another icon when tab isn't selected. I'd like to have this icon on full tab width and height under the text, similar like when one replaces a whole button with an image.

Upvotes: 1

Views: 811

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347334

Take a look at setTabComponent, this will allow you to supply a custom renderer for that tab

You would then need to monitor changes to the tab selection via the changeListener, when the tab changes, you would use the getTabComponentAt method to get the renderer and update it

Upvotes: 2

Related Questions