使用java swing对JTabbedPane中的选项卡进行着色 [英] Colorize a tab in a JTabbedPane using java swing
问题描述
我正在尝试在 JTabbedPane
中更改标签的背景颜色。我试过 JTabbedPane.setBackgroudAt(0,Color.GRAY)
和 JTabbedPane.setBackgroud(Color.GRAY)
和前景也没有,但没有任何反应。我更改了标签内面板的背景,仍然没有。
I am trying to change the background color of my tabs in a JTabbedPane
. I tried JTabbedPane.setBackgroudAt(0, Color.GRAY)
and JTabbedPane.setBackgroud(Color.GRAY)
and the foreground too, but nothing happens. I changed the background of the panel inside the tab, still nothing.
编辑1:我正在使用 UIManager.setLookAndFeel(com .sun.java.swing.plaf.windows.WindowsLookAndFeel);
如果这可以帮助解决方案
Edit 1: I'm using UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
if this can help with the solution
编辑2: 链接到示例, https://www.dropbox.com/s /0krn9vikvkq46mz/JavaApplication4.rar
推荐答案
-
大部分方法为
JTabbedPane
在API中受到保护,无法从Swing方法访问most of method for
JTabbedPane
is protected in the API, and not accesible from Swing methods必须查找
自定义XxxTabbedPaneUI
,覆盖这些方法,并且可以从外部访问have to look for
Custom XxxTabbedPaneUI
, override these methods, and could be accesible from outside正确的方法是实现卡斯特om Look&仅感觉,其中一部分覆盖
JTabbedPane
correct way would be to implement Custom Look & Feel only, part of them override
JTabbedPane
这篇关于使用java swing对JTabbedPane中的选项卡进行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!