It's been a lot of publications about adding "close" button to a tabbedPane, all solutions suggested are really inventive and not easy to find. But we are gonna talk about Mustang "tabComponents feature" because it is the most preferable and clear solution for JTabbedPane customizing.
Since 1.6 three new methods added to JTabbedPane:
we can put a component to a tab with help of
public void setTabComponentAt(int index, Component component)
get this component with
public Component getTabComponentAt(int index)
and test if a component is a tabComponent for this JTabbedPane with
public int indexOfTabComponent(Component tabComponent)
With this three methods we can enrich a JTabbedPane with comboboxes, multiple labels or whatever we want.
Remember that JTabbedPane's tab area is not a real component, it is just an image so to insert a component there we can can draw a fake component in addition to the existing tab's title (it was the only solution before Mustang) or set our own tabComponent which can draw title and icon and contain any other additional components.
Please download source files and go on.
First, let's check how we can add the most wanted