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

后端 未结 3 1854
天涯浪人
天涯浪人 2021-01-06 11:49

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 t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 12:37

    Okay, I found the Problem. In

    package javax.swing.plaf.basic.BasicTabbedPaneUI;
    

    it says something like this

    // Rotate run array so that selected run is first
                if (shouldRotateTabRuns(tabPlacement)) {
                    rotateTabRuns(tabPlacement, selectedRun);
                }
    

    Its a pity that there seems to be no easy set-a-flag-and-there-you-go-way is for changing that.

    Although you should be fine if you omitted the call to rotateTabRuns(tabPlacement, selectedRun); or change shouldRotateTabRuns(tabPlacement) for that matter... however, to do so you would have to override a whole bunch of classes... depending on which plaf you use.

    It inherits like this

    Basic > Synth > Nimbus
    

    And on each L&F-level there are several classes to customize... I didn't count.

    Hope it helps! :D

    Edit Oh yeah... @mkorbel already provided sort of the solution with this aephyr why not use that?

提交回复
热议问题