1

我在使用 UIManager.put(...) 调用绘制 JSplitPane 分隔线时遇到了一些困难。它只是不工作。我正在使用“金属”的外观和感觉,并且必须在创建 GUI 之后进行此更改。我所有其他 UIManager.put(...) 操作似乎都有效,但仅适用于颜色键项目。当一切都说完了,我也使用 SwingUtilities.updateComponentTreeUI(getRootPane()) 。我的代码示例如下。我想知道是否有人建议让我的画家工作。谢谢大家的时间和帮助!

    UIManager.put("SplitPane:SplitPaneDivider[Enabled+Vertical].foregroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    UIManager.put("SplitPane:SplitPaneDivider[Enabled].backgroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    }); 
    UIManager.put("SplitPane:SplitPaneDivider[Enabled].foregroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    }); 
    UIManager.put("SplitPane:SplitPaneDivider[Focused].backgroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    SwingUtilities.updateComponentTreeUI(getRootPane()): 

以上只是我正在尝试做的一个示例。知道为什么它不起作用吗?再次感谢大家的帮助!

4

1 回答 1

2

这些是Nimbus LAFnot the的属性Metal LAF,因此它们将不起作用。

要查看Metal LAF属性,请查看UIManager Defaults,它将显示您可以更改的 UIManager 属性。

于 2015-07-24T22:24:13.597 回答