I want a behavior similar to e.g. Firefox where the list of available tabs does only show up if at least two tabs exist.
I wasn't able to find anything like that, yet.
The best idea I had was changing the layout manually:
While this would probably work it feels like a hack or workaround...
Any better idea?
A solution should ideally work in both Java 1.5 and 1.6... but I'd be happy about a 1.6-only solution, too.
You can override the UI method that calculates the height for the tab button area, forcing the height to 0
when there's only one tab:
tabbed_pane.setUI(new BasicTabbedPaneUI() {
@Override
protected int calculateTabAreaHeight(int tab_placement, int run_count, int max_tab_height) {
if (tabbed_pane.getTabCount() > 1)
return super.calculateTabAreaHeight(tab_placement, run_count, max_tab_height);
else
return 0;
}
});