Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6923305

SynthSliderUI paints the slider track when the slider's "paintTrack" property is set to false

XMLWordPrintable

    • b86
    • generic
    • generic

        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);
            }
        }
        --------------------

              rupashka Pavel Porvatov (Inactive)
              agavrilosunw Alexey Gavrilov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: