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

MetalSliderUI paint wrong vertical disabled filled JSlider for DefaultMetalTheme

XMLWordPrintable

    • b38
    • x86
    • windows_xp
    • Not verified

      FULL PRODUCT VERSION :
      java version "1.6.0_10-beta"
      Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b14)
      Java HotSpot(TM) Client VM (build 11.0-b11, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When using the DefaultMetalTheme for painting an vertical disabled filled JSlider the track will be painted wrong.
      Reason is probably a copy/paste error in
      javax.swing.plaf.metalMetalSliderUI.paintTrack()
      Line 300:
          g.fillRect( fillLeft, fillTop, fillRight - fillLeft, trackBottom - trackTop );
      should be
          g.fillRect( fillLeft, fillTop, fillRight - fillLeft, fillBottom - fillTop );

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a UI with DefaultMetalTheme
      and add a vertical JSlider which is disabled and filled:
        slider.setEnabled(false);
        slider.putClientProperty("JSlider.isFilled", true);
      The filled track of the Slider is painted wrong, especially if it is set to inverted.



      REPRODUCIBILITY :
      This bug can be reproduced rarely.

      ---------- BEGIN SOURCE ----------
      /**
       * This class shows a JFram with 4 vertical sliders:
       * enabled + bottom-up
       * enabled + top-down
       * disabled + bottom-up
       * disabled + top-down
       * The enabled Sliders where painted correctly the disabled not.
       */
      public class SliderTest {

      public static void main(String[] args)
      {
      JPanel panel = new JPanel(new FlowLayout());
      panel.add(createSlider(true, true, true, false));
      panel.add(createSlider(true, true, true, true));
      panel.add(createSlider(true, false, true, false));
      panel.add(createSlider(true, false, true, true));
      MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
      JFrame frame = new JFrame("Window Title");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().add(panel);
      frame.pack();
      frame.setVisible(true);
      }

      private static JSlider createSlider(boolean vertical, boolean disabled, boolean filled, boolean inverted)
      {
      JSlider slider = new JSlider(vertical? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL, 10, 30, 20);
      if (!disabled)
      slider.setEnabled(false);
      if (filled)
      slider.putClientProperty("JSlider.isFilled", true);
      if (inverted)
      slider.setInverted(true);
      return slider;
      }
      }
      ---------- END SOURCE ----------

            rupashka Pavel Porvatov (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: