My JScrollPane is transparent by setting the Viewport.setOpaque(false). Works fine, but I'd like to have the JScrollBar (Vertical in this case) transparent too. scrollBar.setOpaque(false) doesn't do anything, nor does setting scrollBar foreground/background colors do anything.
In looking at JScrollBar source code, I don't see where the drawing takes place. Or is that actually in the JScrollPane?
I tried setting the scrollbar width to zero, but nothing happened. I got scrollBar = scrollPane.getVerticalScrollBar() then d = scrollBar.getSize(), scrollBar.setSize(new Dimension(0, d.height) ) before and after repainting.
BTW UIManager.put("JScrollBar.(anything)", (something)) doesn't do anything either.
I'm working on a Mac, so I'm seeing the Mac L&F. But I'd like the transparency to work on all systems. Does this mean I need to modify all the L&F's to make this work?
Ah! I set the L&F to "CrossPlatform", then setOpaque(false) on the scrollBar. The scrollBar track is now transparent!
IDEALLY, I'd like the track borders and the up/down buttons to disappear. But Even with "CrossPlatform" L & F I haven't been able to use UI.Manager.put to change anything. Where should the
UIManager.put(.) be done?
I was able to set the width to zero with Michael Dunn's approach, but the result wasn't what I wanted.
Sticking to the CrossPlatform L&F and a simple setOpaque(false) comes very close to what was needed. There is an still unalterable white box around the transparent scroll bar. It would be nice to colorize the box to another color, but it appears not to be in the range of UIManager constants.
I've considered modfying the MetalScrollBarUI, however, that looks really complicated to do.