javaswinglook-and-feeluimanagerswingutilities

Java metal look and feel UIManager painter for the SplitPane divider


I'm having a bit of difficulty painting the JSplitPane divider with a UIManager.put(...) call. It's just not working. I'm using the "Metal" look and feel, and this change has to happen after the GUI is already created. All of my other UIManager.put(...) operations seem to work but only for Color key items. I also utilize SwingUtilities.updateComponentTreeUI(getRootPane()) when everything is said and done. My code example is below. I was wondering if anyone has a suggestion to get my painter working. Thank you all for your time and help!

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

The above is just a sample of what I'm attempting to do. Any idea why it's not working? Again, thank you all for your help!


Solution

  • Those are properties for the Nimbus LAF not the Metal LAF, so they will not work.

    To see the Metal LAF properties check out UIManager Defaults which will display the UIManager properties that you might be able to change.