JDK-6860438 : [Nimbus] Code to globally set slider's thumb background doesn't work as specified
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2009-07-14
  • Updated: 2011-01-19
  • Resolved: 2010-02-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 Other
7 b84Fixed OpenJDK6Fixed
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 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.
24-12-2009

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".
22-12-2009