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

GridBagConstraints.ipadx visually also sets ipady on JScrollBar with WIndowsL&F

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

      On Java 5, this only happens when used in a CardLayout Container:

      java version "1.5.0_11"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

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

      A DESCRIPTION OF THE PROBLEM :
      When putting a horizontal JScrollBar into a Container with GridBagLayout, and doing internal padding in y-direction with ipady, the scroll arrows resize in both y AND x direction.

      It only happens if used with WindowsLookAndFeel or WindowsClassicLookAndFeel. A very negative visual side effect of this is that the resized arrows look really bad then.

      There is different behaviour depending on the weight* parameters of GridBagConstraints and the orientation of the JScrollBar. With vertical orientated JScrollPane, it only happens, if weighty is more than 0 and the fill parameter fills in y-direction.

      In Java 5, this only happens, if you put your Panel into a CardLayout Container.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set the Look&Feel to WindowsLookAndFeel or WindowsClassicLookAndFeel.

      Put a horizontally oriented JScrollBar into a JPanel with GridBagLayout, and set the GridBagConstraints ipady to a value of higher than 0, e.g. 15.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The scroll buttons left and right of the JScrollBar should be enlarged into the y-direction only, and not in the x-direction as well.

      If it is meant to be resized in both directions by design in this look and feel, the visual appearance of the buttons should remain 'realistic', and the behaviour should be consistent with horizontal and vertical orientation and different weight and fill values.

      ACTUAL -
      Buttons of the JScrollBar resize in both x- and y-direction, and the visual appearance of the buttons is really bad.

      This happens under the conditions:

      - Java 6 and JScrollBar with horizontal orientation
      - Java 6 and JScrollBar with vertical orientation AND weighty > 0 AND the fill parameter fills in VERTICAL direction

      In Java 5, the JScrollBar has to become packed into a CardLayout Container additionally.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class SBTest1
      extends JFrame {
      public SBTest1() {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(400,400);

      try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
      } catch (Exception e) {
      System.err.println("This program has to be run with WindowsLookAndFeel. Aborting.");
      System.exit(1);
      }
      GridBagLayout gl = new GridBagLayout();
      GridBagConstraints gc = new GridBagConstraints();
      setLayout(gl);

      JScrollBar jsbZoom = new JScrollBar(JScrollBar.VERTICAL);
      gc.weighty = 1;
      gc.fill = GridBagConstraints.BOTH;
      gc.ipadx = 15;
      gl.setConstraints(jsbZoom, gc);
      add(jsbZoom, gc);

      setVisible(true);
      }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              peterz Peter Zhelezniakov
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: