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

BoxLayout cuts off large components

    XMLWordPrintable

Details

    • Cause Known
    • generic, x86
    • generic, windows_2000, windows_xp

    Description

      Name: jk109818 Date: 08/29/2003


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

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Large components are cut off when added to a boxlayout component. Several thousand lines of a text component seems to be the boundry.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a large JEditorPane (like 5000 lines)
      2. Add the JEditorPane to a JPanel (any layout)
      3. Add the JPanel to another JPanel (BoxLayout)
      4. Add that JPanel to a JScrollPane in the content pane of a JFrame

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      You should see all 5000 lines.
      ACTUAL -
      You see about 2000 lines

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.BoxLayout;
      import javax.swing.JEditorPane;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import java.awt.GridLayout;
      import javax.swing.JScrollPane;

      public class BoxLayoutTester {

      public void test(){
      StringBuffer theContent = new StringBuffer();

      for (int i = 0; i < 5000; i++)
      theContent.append("This is line number " + i + ".\n");

      JFrame theFrame = new JFrame("BoxLayoutTester");
      theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JEditorPane jep = new JEditorPane();
      jep.setText(theContent.toString());
      jep.setEditable(false);

      // add the large editor pane to a JPanel with any layout
      JPanel aPanel = new JPanel();
      aPanel.setLayout(new GridLayout(0,1));
      aPanel.add(jep);

      // add the large JPanel to a box layout JPanel
      JPanel boxLayoutPanel = new JPanel();
      boxLayoutPanel.setLayout(new BoxLayout(boxLayoutPanel, BoxLayout.Y_AXIS));
      boxLayoutPanel.add(aPanel);

      theFrame.getContentPane().add(new JScrollPane(boxLayoutPanel));
      theFrame.setSize(600, 600);
      theFrame.setVisible(true);
      }
          
      public static void main(String[] args) {
      BoxLayoutTester blt = new BoxLayoutTester();

      blt.test();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use BoxLayout
      (Incident Review ID: 200842)
      ======================================================================

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Imported:
              Indexed: