【问题标题】:How can I customize the color of the tabbedPane at swing builder?如何在 swing builder 中自定义 tabbedPane 的颜色?
【发布时间】:2011-01-31 16:31:27
【问题描述】:

我想自定义 tabbedPane 的颜色以适合我的 gui 主题,但我不知道该怎么做。我已经尝试了很多代码,但仍然没有任何反应。

这是我的指南...

提前 ^_^

【问题讨论】:

  • 您是在尝试调整选项卡的颜色还是内部组件背景(JTextArea)?
  • 实际上这是我的 2 个主要问题...标签的颜色,我想减少 TextArea 的不透明度(我希望它是透明的)以在后面显示图像(我在 jLabel 上附上了图片)..

标签: java swingbuilder swing-app-framework


【解决方案1】:

您可以在创建 GUI 之前进行几个 UIManager 设置,但它们适用于每个 JTabbedPane: 这将更改选定的选项卡颜色。

UIManager.put("TabbedPane.selected", Color.RED);

我没有看到边框设置,但您可以像这样隐藏它:

UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));

最后,您可以像这样更改选项卡窗格的背景:

tab.setBackground(Color.BLUE);

【讨论】:

    【解决方案2】:

    对于 JTabbedPane 的外观和感觉,设置 UIManager 设置,如本文 Controlling Color in Java Tabbed Pane 中所述

    相关代码:

      UIManager.put("TabbedPane.contentAreaColor ",ColorUIResource.GREEN);
      UIManager.put("TabbedPane.selected",ColorUIResource.GREEN);
      UIManager.put("TabbedPane.background",ColorUIResource.GREEN);
      UIManager.put("TabbedPane.shadow",ColorUIResource.GREEN);
    
      // now construct the tabbed pane
      tab=new JTabbedPane();
    

    【讨论】:

      猜你喜欢
      • 2016-04-20
      • 2011-02-22
      • 2014-11-14
      • 2020-02-22
      • 2012-02-11
      • 2021-05-20
      • 2015-02-14
      • 2017-08-29
      • 2016-01-25
      相关资源
      最近更新 更多