Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change the color of a JScrollBar  RSS feed

 
Ann
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is it possible to change the color of a JScrollBar ?
We've tried the .setBackground(Color c) method but it only changed the background of the middle part.
Isn't it possible to change the color of the other parts too ?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ann & Kenny,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. If that ampersand were to disappear, I'm sure folks 'round here would be satisfied.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, not really... setBackground() changes the color of the 'track' (the part the scrollbar moves in), but there's not really a way to access the color of the 'thumb' (the part of the scrollbar that is moved). setForeground() would make sense here, but doesn't seem to do anything at all.

However, you can use:


To change *all* the color of all the 'thumbs' of all the scrollbars in your application, but this only seems to work in Motif look and feel. It doesn't do anything in Metal (default) and it changes the color of both the thumb and the arrows at the ends of the scrollbar in Windows L&F.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!