Article View: borland.public.jbuilder.java.api
Article #2915JScrollPane/JScrollBar Colors Not Correct
From: ccocchia
Date: Mon, 05 Oct 1998 00:00
Date: Mon, 05 Oct 1998 00:00
49 lines
2927 bytes
2927 bytes
I have a JTable encapsulated by a JScrollPane. I'm forcing a horizontal
scrollbar to always appear in the JScrollPane. Since I'm using a different
desktop background scheme other than the default MS Windows colors, the colors
of the scrollbar are not correct. I'm able to set all the colors of the
JScrollBar except the line/unit increment and decrement arrow portions. Does
anyone know the correct UIDefault values to change for these? Here's how I'm
doing it:
// Set the JScrollBar color values.
ColorUIResource control;
ColorUIResource controlShadow;
ColorUIResource controlHighlight;
ColorUIResource controlDkShadow;
control = new ColorUIResource(SystemColor.control);
if (SystemColor.controlLtHighlight.getRGB() == 0xFFFFFF) controlHighlight
= new ColorUIResource(SystemColor.controlHighlight); else controlHighlight
= new ColorUIResource(SystemColor.controlLtHighlight);
controlShadow = new ColorUIResource(SystemColor.controlShadow);
controlDkShadow = new ColorUIResource(Color.black);
// Put the system colors into the UI's default hashtable and force a
// PropertyChangeEvent to occur by calling UIDefaults.put().
UIDefaults defaults = UIManager.getDefaults();
defaults.put("ScrollBar.background",controlHighlight);
defaults.put("ScrollBar.foreground",control);
defaults.put("ScrollBar.track",controlHighlight);
defaults.put("ScrollBar.trackHighlight",controlDkShadow);
defaults.put("ScrollBar.thumb",control);
defaults.put("ScrollBar.thumbHighlight",controlHighlight);
defaults.put("ScrollBar.thumbDarkShadow",controlDkShadow);
defaults.put("ScrollBar.thumbLightShadow",controlShadow);
scrollPane = new JScrollPane(resultsGrid);
scrollPane.getViewport().setBackground(Color.white);
scrollPane.setHorizontalScrollBarPolicy
(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy
(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
Any help would be appreciated. Thanks.
Charlie Cocchiaro
ccocchia@unifi.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Technical Details
Message-ID:
<6vb8bi$lc0$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,4fbbb91aa58e0ea2,start X-Google-Attributes: gid1089d0,public From: ccocchia@unifi.com Subject: JScrollPane/JScrollBar Colors Not Correct Date: 1998/10/05 Message-ID: <6vb8bi$lc0$1@nnrp1.dejanews.com> X-Deja-AN: 397993559 X-Http-Proxy: 1.1 x13.dejanews.com:80 (Squid/1.1.22) for client 206.15.188.17 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Oct 05 19:57:38 1998 GMT Newsgroups: borland.public.jbuilder.java.api X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)