Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing color of JScrollBar buttons

433 views
Skip to first unread message

Justin Turner

unread,
Dec 18, 2001, 11:57:06 AM12/18/01
to
Hi. I'm trying to change the color of the arrow buttons on a
JScrollBar. I used various calls to UIManager.put(...) to change the
rest of my components, but the scrollbar buttons don't seem to respond
to any of the settings.
Can anyone tell me what I need to do?

I found a similar post from about a year ago, but I'm new to java and
didn't understand the solution posted. That solution was:

"The scrollbar uses the BasicArrowButton class for the arrow buttons.
The
colors used in drawing these come from the UI manager
getColor("controlXXXX"). If you set these colors, then all such
controls
will be affected. If this is not what you want (which I'm assuming it
isn't)
then you will have to subclass BasicScrollBarUI, and override
createDecreaseButton and createIncreaseButton methods to create an
instance
of your subclassed BasicArrowButton class which uses custom colors to
draw
instead of getting them from the UIManager."

Thanks in advance for any assistance.

Linda Radecke

unread,
Dec 20, 2001, 7:35:51 AM12/20/01
to

Justin Turner wrote:

I haven't looked at this posting a year ago, but something
similar came up in October, you might have a look at this:


Newsgroups:comp.lang.java.gui
Subject: Re:signs for up and down arrows
in a combo box or scroll pane...
Date:Sat, 06 Oct 2001 01:03:57 +0200
Message-ID:<3BBE3C5D...@jalice.ch>

If you are new to this I don't recommend to do this, though,
or to deal with custom L&F-implementations. What you can do
easily is to change the background of this part, e.g like this:

Color color = new Color(....);

JScrollPane scroll = new JScrollPane();

scroll.getHorizontalScrollBar().getComponent(0)
.setBackground(color);
scroll.getHorizontalScrollBar().getComponent(1)
.setBackground(color);

the same with: getVerticalScrollBar


this lets the arrow itself black but changes the background
of this scrollbarcomponent.

Hope this helps


Linda
--
(=)
/ li...@jalice.ch - http://www.jalice.net
(=)
/ l.ra...@hswzfh.ch - http://www.hswzfh.ch
(=)


Justin Turner

unread,
Dec 20, 2001, 12:58:34 PM12/20/01
to
Linda,

This is exactly what I needed. Thanks much for the help.

Justin

0 new messages