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

JTextPane breaks GridBagLayout

XMLWordPrintable



      Name: gm110360 Date: 07/19/2004


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


      ADDITIONAL OS VERSION INFORMATION :
      Linux vova.labs.intellij.net 2.6.6-1.435.2.3smp #1 SMP Thu Jul 1 08:36:21 EDT 2004 i686 i686 i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The attached sample demostrate how wrong GridBagLayout behaves if container contains JScrollPane with JTextPane inside.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile and run sample code
      2. Shrink frame a little

      The bug is perfectly reproducible under Windows. It's also reproducible under J2SDK 5.0

      ACTUAL -
      JList grows to the size of whole frame and JTextPane is _contantly_ flickering.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com;

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

      /**
       * @author Vladimir Kondratyev
       */
      public class Test {
        public static void main(String[] args) {
          final JFrame jFrame = new JFrame();

          final JPanel cp = new JPanel(new GridBagLayout());
          cp.add(
            new JScrollPane(new JList(new String[]{"One, Two, Three"})),
            new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)
          );

          final JTextPane view = new JTextPane();
          view.setText("Long words long words long words long words long "
                    + "words long words long words long words long words long "
                    + "words ");
          cp.add(
            new JScrollPane(view),
            new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)
          );

          jFrame.setContentPane(cp);
          jFrame.pack();
          jFrame.show();
        }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 286395)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: