4

I want to completely change the look of a scollbar but overriding JScrollBar and the paintComponent method doesn't work, the track and thumb are painted but the left and right arrows stay the same.
I am also using them inside a JScrollPane and using
setHorizontalScrollBar( new CustomScrollBar() ) to set the scroll bars to my custom scroll bars but it doesn't work so well, the horizontal scrollbar doesn't change it's orientation, it doesn't change to a vertical scroll bar.

How do I paint a completely new JScrollBar and use it within a JScrollPane?

skaffman
  • 398,947
  • 96
  • 818
  • 769
cmann
  • 1,920
  • 4
  • 21
  • 33

1 Answers1

6

In a nutshell you need to subclass ScrollBarUI with your own implementation and then register it with the UIManager.

There's a full article here.

Adamski
  • 54,009
  • 15
  • 113
  • 152
  • It looks like a good article but I was hoping for something simpler. That method actually creates an entirely new scrollbar, it defines completely new functionality. All I want is to change the look, the rest of the scrollbar must stay exactly the same. – cmann Aug 18 '09 at 08:46
  • That article was pretty much useless for me, the code doesn't work by copypasting and i don't know where did WindowUtils came from, i downloaded jna-utils and nothing. – Wesos de Queso Jun 05 '17 at 05:31