Search code examples
javaswingconstantsjtabbedpanenimbus

JTabbedPane: avoid automatic re-ordering tabs if stacked / Nimbus


a JTabbedPane is just what I need for my purpose. I have very limited horizontal space, so my Tabs get stacked, which is perfectly ok.

But the default behaviour is that if user clicks on a Tab, the *Tabs get re-sorted so that the active Tab becomes the lower-mos*t. What looks very intuitive and logical in theory, is a nightmare in practical use, because the users loose track of "which was which". Its just simply plain confusing, I am told again and again.

I guess it should be possible to override some method of the UI to avoid this behaviour (and I dont care whether this would be physically possible with paper cards :-) .

Has anyone any idea where I need to do that? I am using Nimbus LAF, which does not seem to make it easier.

(I thought about using radiobuttons/cardLayout, but I need to put a custom panel in the tab title, and radiobuttons can only have a string or icon. Same for JToggleButton...)

Any hints are greatly welcome!

Thanks & Kind regards, Philipp


Solution

  • The original question was for Nimbus but I ran into the same issue with FlatLaf. I got around the problem by setting this option during the application initialization:

    UIManager.getDefaults().put("TabbedPane.rotateTabRuns", false);