JTabbedPane:如果堆叠/ Nimbus,则避免自动重新排序选项卡 [英] JTabbedPane: avoid automatic re-ordering tabs if stacked / Nimbus

查看:74
本文介绍了JTabbedPane:如果堆叠/ Nimbus,则避免自动重新排序选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JTabbedPane就是我的目的所需要的。
我的水平空间非常有限,所以我的Tabs堆叠,这是完全可以的。

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.

但默认行为是,如果用户点击Tab, * 标签被重新排序,以便活动标签成为低级别的 * t。在理论上看起来非常直观和合乎逻辑的是实际使用中的噩梦,因为用户松散地追踪哪个是哪个。它只是简单的混乱,我一次又一次地被告知。

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.

我想应该可以覆盖UI的某些方法来避免这种行为(我不在乎)是否用纸卡实际上是可能的:-)。

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 :-) .

有谁知道我需要做什么?我正在使用Nimbus LAF,这似乎并不容易。

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

(我考虑使用radiobuttons / cardLayout,但我需要在选项卡中放置一个自定义面板title和radiobuttons只能有一个字符串或图标。相同的JToggleButton ...)

(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!

谢谢&亲切的问候,
Philipp

Thanks & Kind regards, Philipp

推荐答案

好的,我找到了问题。在

Okay, I found the Problem. In

package javax.swing.plaf.basic.BasicTabbedPaneUI;

它说的是这样的话

// 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.

虽然你省略了对 rotateTabRuns(tabPlacement, selectRun); 或更改 shouldRotateTabRuns(tabPlacement)就此而言......但是,要做到这一点,你必须覆盖一大堆类......取决于你使用的plaf。

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.

它继承了这样的

Basic > Synth > Nimbus

在每个L& F级别,有几个类可以自定义...我没有' t count。

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

希望它有所帮助! :D

Hope it helps! :D

编辑
哦是的... @mkorbel已经提供了这种 aephyr的解决方案为什么不使用它?

这篇关于JTabbedPane:如果堆叠/ Nimbus,则避免自动重新排序选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆