-
Enhancement
-
Resolution: Fixed
-
P5
-
6
-
b38
-
x86
-
windows_xp
-
Not verified
A DESCRIPTION OF THE REQUEST :
It used to be that JSlider under metal LnF would fill the left side of its track if putClientProperty("JSlider.isFilled", Boolean.TRUE) was specified, otherwise it the entire track would be unfilled. (Image at http://java.sun.com/products/jlf/ed2/book/HIG.Controls7.html )
With the advent of the Ocean theme with Tiger, the programmer can no longer control this. JSlider always fills half the track. MetalSliderUI does this:
public void paintTrack(Graphics g) {
if (MetalLookAndFeel.usingOcean()) {
oceanPaintTrack(g); // private method that ignores "JSlider.isFilled"
return;
}
...
}
I ask that JSlider fill control be returned to the programmer, at least under Metal. One way is to change oceanPaintTrack() to not fill the track when putClientProperty("JSlider.isFilled", Boolean.FALSE) has been set.
I've submitted this as an RFE but in a sense this is a regression because existing metal JSliders behave differently between 1.4+ and 5.0+.
JUSTIFICATION :
This isn't a big deal for most JSliders but it is for some customizations (such as ones supporting multiple thumbs).
If Ocean were an LnF, not just a theme, it would be possible to call mySlider.setUI(new MetalSliderUI()) to allow 'mySlider' to honor the "JSlider.isFilled" client property without messing with all the other sliders. Alas, Ocean is part of Metal so this doesn't work. [Can do mySlider.setUI(new BasicSliderUI(null)) but the resulting UI is ugly.] It would be nice to allow my users to run Ocean without having to reimplement most of MetalSliderUI.
Nicer still would be a true API for track filling that would allow arbitrary regions of the track to be filled, but I won't hold my breath for that.
CUSTOMER SUBMITTED WORKAROUND :
override paintTrack. something like:
@Override
public void paintTrack(Graphics g) {
Rectangle save = thumbRect;
thumbRect = (slider.getOrientation() == JSlider.HORIZONTAL)
? new Rectangle(4, save.y, save.width, save.height)
: new Rectangle(save.x, slider.getHeight()-save.height, save.width, save.height);
super.paintTrack(g);
thumbRect = save;
}
This sort of works, but it's fragile and it still fills a couple pixels worth of the track.
It used to be that JSlider under metal LnF would fill the left side of its track if putClientProperty("JSlider.isFilled", Boolean.TRUE) was specified, otherwise it the entire track would be unfilled. (Image at http://java.sun.com/products/jlf/ed2/book/HIG.Controls7.html )
With the advent of the Ocean theme with Tiger, the programmer can no longer control this. JSlider always fills half the track. MetalSliderUI does this:
public void paintTrack(Graphics g) {
if (MetalLookAndFeel.usingOcean()) {
oceanPaintTrack(g); // private method that ignores "JSlider.isFilled"
return;
}
...
}
I ask that JSlider fill control be returned to the programmer, at least under Metal. One way is to change oceanPaintTrack() to not fill the track when putClientProperty("JSlider.isFilled", Boolean.FALSE) has been set.
I've submitted this as an RFE but in a sense this is a regression because existing metal JSliders behave differently between 1.4+ and 5.0+.
JUSTIFICATION :
This isn't a big deal for most JSliders but it is for some customizations (such as ones supporting multiple thumbs).
If Ocean were an LnF, not just a theme, it would be possible to call mySlider.setUI(new MetalSliderUI()) to allow 'mySlider' to honor the "JSlider.isFilled" client property without messing with all the other sliders. Alas, Ocean is part of Metal so this doesn't work. [Can do mySlider.setUI(new BasicSliderUI(null)) but the resulting UI is ugly.] It would be nice to allow my users to run Ocean without having to reimplement most of MetalSliderUI.
Nicer still would be a true API for track filling that would allow arbitrary regions of the track to be filled, but I won't hold my breath for that.
CUSTOMER SUBMITTED WORKAROUND :
override paintTrack. something like:
@Override
public void paintTrack(Graphics g) {
Rectangle save = thumbRect;
thumbRect = (slider.getOrientation() == JSlider.HORIZONTAL)
? new Rectangle(4, save.y, save.width, save.height)
: new Rectangle(save.x, slider.getHeight()-save.height, save.width, save.height);
super.paintTrack(g);
thumbRect = save;
}
This sort of works, but it's fragile and it still fills a couple pixels worth of the track.