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

JScrollBar leaves behind clutter for non-integer UI scales

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11

      A DESCRIPTION OF THE PROBLEM :
      For some (most) non-integer UI scales, JScrollBar sliders leave behind "lines" when moved in the positive direction. This does not happen for scrollbars in a JScrollPane, and appears not to happen with the Windows Look&Feels. I have not tested on MacOS or Linux.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the code and run on Windows with: java -Dsun.java2d.uiScale=2.3 ScrollBarBug
      Click and drag the scrollbar to the right.
      Click the right arrow scrollbar button.

      Note that if the screen scaling on Windows is already non-integer, this can happen when running without the uiScale specification.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect normal scrollbar behavior.
      ACTUAL -
      Lines (copies of the edge of the scrollbar slider, I suppose) are left behind when moving the scrollbar in the positive direction. With a click-and-drag, they are cleaned up on release. With right arrow clicks, they remain. The slider also seems to change to a slightly incorrect size when dragging, then is restored to the correct size on release.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;

      public class ScrollBarBug {
         public static void main(String[] args) {
            SwingUtilities.invokeLater(()->test());
         }
         public static void test() {
            JFrame f = new JFrame();
            JPanel panel = new JPanel(new BorderLayout());
            JScrollBar sb = new JScrollBar(JScrollBar.HORIZONTAL);
            panel.add(sb, "South");
            f.setContentPane(panel);
            f.setSize(800, 200);
            f.setVisible(true);
         }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: