JDK-6923305 : SynthSliderUI paints the slider track when the slider's "paintTrack" property is set to false
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10,7
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-02-04
  • Updated: 2012-03-22
  • Resolved: 2010-03-17
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 6 JDK 7
6u21Fixed 7 b86Fixed
Related Reports
Duplicate :  
Description
The SynthSliderUI class invokes the paintTrack method even though the "paintTrack" property of a slider component being painted was set to false. The spec on the JSlider.html#setPaintTrack(boolean) says that the method controls whether or not to paint the slider track.

Here is a sample program that demonstrates this:

------------------
import javax.swing.*;
import javax.swing.plaf.synth.*;
import java.awt.*;

public class Test {

    public static void main(String[] args) throws Exception {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                runTest();
            }
        });
    }

    private static void runTest() {
        try {
            UIManager.setLookAndFeel(new SynthLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
            throw new RuntimeException(e);
        }
        JSlider slider = new JSlider();
        slider.setPaintTrack(false);
        slider.setUI(new SynthSliderUI(slider) {

            @Override
            protected void paintTrack(SynthContext context, Graphics g,
                    Rectangle trackBounds) {
                super.paintTrack(context, g, trackBounds);
                System.out.println("paintTrack called");
            }

        });
        JFrame jFrame = new JFrame();
        jFrame.getContentPane().add(slider);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.pack();
        jFrame.setVisible(true);
    }
}
--------------------

Comments
EVALUATION The SynthSliderUI#paintTrack method shouldn't be invoked in case the paintTrack property is false. A part of the BasicSliderUI#paint method can be an example of correct code: if ( slider.getPaintTrack() && clip.intersects( trackRect ) ) { paintTrack( g ); }
19-02-2010