1

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!

user1457114
  • 127
  • 1
  • 1
  • 5

1 Answers1

2

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.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • Thank you! :) I suppose I was thinking I could get away with Nimbus keys, got sloppy and didn't think to see if Metal supported them. – user1457114 Jul 24 '15 at 23:43
  • Sadly it didn't get me closer to painting the divider, or other items like the slider. I have a bad feeling this road will lead to custom swing component painting for a few things. Thanks for your help though! – user1457114 Jul 24 '15 at 23:44