United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6860438 [Nimbus] Code to globally set slider's thumb background doesn't work as specified
JDK-6860438 : [Nimbus] Code to globally set slider's thumb background doesn't work as specified

Details
Type:
Bug
Submit Date:
2009-07-14
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2010-02-16
Component:
client-libs
OS:
linux_ubuntu
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
Attached is the example.  This little example is a modification of a demo written by Jasper Potts.  It shows two problems:

1. UIManager.put() is supposed to work, but I had to use UIManager.getLookAndFeelDefaults().put, even though I had already set the L&F.

2. In order to the get background painter for the thumb to work, I couldn't just set the Slider:SliderThumb.background property (as specified), I had to set the seven keys for the background states.

See the example for more info.

                                    

Comments
EVALUATION

1. UIManager.put() is supposed to work, but I had to use UIManager.getLookAndFeelDefaults().put, even though I had already set the L&F.

The reason is that methods get() and entrySet() in MultiUIDefaults are not implemented consistently. get() first examines the inherited hashtable, then the tables array. entrySet() does not check inherited table at all, and examines the tables in the array in reverse order. This flaw stayed undiscovered for years, as NimbusLAF was the only class that called entrySet().

2. In order to the get background painter for the thumb to work, I couldn't just set the Slider:SliderThumb.background property (as specified), I had to set the seven keys for the background states.

I'm afraid nothing can be done here, as NimbusDefaults define painters for many specific states, e.g. "Slider:SliderThumb[Focused].backgroundPainter". These take precedence over just "Slider:SliderThumb.backgroundPainter", because they are more specific. An alternative is to remove painters for all states from the defaults table, then define a painter for "Slider:SliderThumb.backgroundPainter".
                                     
2009-12-22
EVALUATION

More on problem 1:
MultiUIDefaults extends Hashtable, so technically it should override about all methods inherited from Hashtable. This would be a huge task, and it's unclear whether there would be any benefit. For now i'm fixing just methods that are overridden in MultiUIDefaults.
                                     
2009-12-24



Hardware and Software, Engineered to Work Together