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

Layout problems with JTextPane and small fonts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      Name: bsC130419 Date: 07/16/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)


      When displaying text with a small font (e.g. 6 pt), JTextPane leaves extra
      space between the last line and the rest of the text. The example application
      below illustrates the problem. As an interesting note, the problem exists with
      and without the "i18n" property being set to true. I would have expected
      different results because the property changes the GlyphPainter that is used.

      public class Test {
          public static void main( String args[]) {
      try {
      javax.swing.JFrame frame = new javax.swing.JFrame();
      frame.getContentPane().setLayout( new java.awt.BorderLayout());
      frame.setSize( 400, 300);
      frame.addWindowListener( new java.awt.event.WindowAdapter() {
      public void windowClosing( java.awt.event.WindowEvent
      event) {
      System.exit(0);
      }
      });

      javax.swing.JTextPane textPane = new javax.swing.JTextPane();
      javax.swing.text.MutableAttributeSet attributeSet = new
      javax.swing.text.SimpleAttributeSet();
      javax.swing.text.StyleConstants.setFontFamily(
      attributeSet, "serif");
      javax.swing.text.StyleConstants.setFontSize( attributeSet, 6);
      textPane.getDocument().insertString( 0, "The Java language provides
      special support for the string concatentation operator ( + ), and for
      conversion of other objects to strings. String concatenation is implemented
      through the StringBuffer class and its append method. String conversions are
      implemented through the method toString, defined by Object and inherited by all
      classes in Java. For additional information on string concatenation and
      conversion, see Gosling, Joy, and Steele, The Java Language Specification.The
      Java language provides special support for the string concatentation operator (
      + ), and for conversion of other objects to strings. String concatenation is
      implemented through the StringBuffer class and its append method. String
      conversions are implemented through the method toString, defined by Object and
      inherited by all classes in Java. For additional information on string
      concatenation and conversion, see Gosling, Joy, and Steele, The Java Language
      Specification.The Java language provides special support for the string
      concatentation operator ( + ), and for conversion of other objects to strings.
      String concatenation is implemented through the StringBuffer class and its
      append method. String conversions are implemented through the method toString,
      defined by Object and inherited by all classes in Java. For additional
      information on string concatenation and conversion, see Gosling, Joy, and
      Steele, The Java Language Specification.", attributeSet);
      frame.getContentPane().add( textPane, java.awt.BorderLayout.CENTER);

      frame.setVisible( true);
      }
      catch( Exception ex) {
      ex.printStackTrace();
      }
          }
      }
      (Review ID: 128133)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: