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

BoxLayout does not respect components preferred widths

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.4.1
    • client-libs

      Name: jk109818 Date: 03/17/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
      Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      BoxLayout sizes components incorrectly.
      As can be seen components end up being xAlignment * preferred size shorter than they are meant to be.
      (Related to bug id: 4140481)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      components to have their preferred widths
      components are xAlignment * their preferred widths shorter than their preferred widths

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Test {
        public static void main(String[] args) {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          Container contentPane = frame.getContentPane();
          contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
          JTree tree = new JTree();
          tree.setAlignmentX(0.1f);
          contentPane.add(tree);
          tree = new JTree();
          tree.setAlignmentX(0.5f);
          contentPane.add(tree);
          tree = new JTree();
          tree.setAlignmentX(0.9f);
          contentPane.add(tree);
          frame.pack();
          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------
      (Review ID: 182028)
      ======================================================================

            Unassigned Unassigned
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: