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

BoxLayout grows component when window shrinks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.2.2
    • client-libs

      Compile and run the following test case:

      import java.awt.*;
      import javax.swing.*;

      public class Sizes {
          
          public static void main(String[] args) throws Exception {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.X_AXIS));

              JToggleButton button1 = new JToggleButton("Testing 123456789");

              f.getContentPane().add(button1);

              button1.setPreferredSize(new Dimension(200, button1.getPreferredSize().height));
              button1.setMinimumSize(new Dimension(200, button1.getMinimumSize().height));

              f.pack();
              f.setVisible(true);
              
          }
      }

      When it launches, notice that the button doesn't fill the width. Now resize slightly smaller and see that the button now fills the width. This behavior of making the component grow when the window is smaller seems very odd.

      Note: This is not a regression in a recent release. It works this way in 1.2.2. I'm not saying it MUST be fixed, but it should be investigated.

            Unassigned Unassigned
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: