使用java swing对JTabbedPane中的选项卡进行着色 [英] Colorize a tab in a JTabbedPane using java swing

查看:324
本文介绍了使用java swing对JTabbedPane中的选项卡进行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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

      自定义XxxTabbedPaneUI

      这篇关于使用java swing对JTabbedPane中的选项卡进行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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