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

JTextPane Line Spacing differs from JRE1.5

XMLWordPrintable

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

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]
      Linux donald 2.6.20-1.2944.fc6

      OS doesn't seam to matter

      A DESCRIPTION OF THE PROBLEM :
      JTextPane line spacing in JRE1.6 differs from JRE1.5 when using some fonts, not all though. I can't seem to find what the defining factor is, but both Arial and Times New Roman cause the problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the supplied code in both JRE1.5 and JRE1.6

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect the total space used to render the text to be the same.
      ACTUAL -
      There is a 20 pixel difference between versions.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No Error message

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Rectangle;

      import javax.swing.*;
      import javax.swing.text.*;

      public class TestModelToView extends JFrame {

      public TestModelToView(){
      JTextPane tp = new JTextPane();
      String t = "Waterfront Blues Festival July 4th-8th\r\n"+
      "Held on the waterfront, the five-day Waterfront Blues Festival \r\n"+
      "brings people from all over the state the hear some of the best \r\n"+
      "blues bands from all over the world and watch fireworks on the \r\n"+
      "Fourth of July. \r\n"+
      "\r\n"+
      "Mt. Hood Jazz Festival August 4th-6th\r\n"+
      "One of the nation's premiere jazz festivals featuring local talent as \r\n"+
      "well as some of the most well-known jazz musicians from the \r\n"+
      "Northwest and across the nation. This festival is held the first two \r\n"+
      "weekends in August at various venues in and around Portland.\r\n"+
      "\r\n"+
      "Vancouver Wine and Jazz Festival August 24th-26th\r\n"+
      "Esther Short Park in downtown Vancouver, Washington hosts \r\n"+
      "internationally acclaimed jazz artists. Other features of this annual \r\n"+
      "summertime fes;tival are great wines, fine cuisine, and artwork by \r\n"+
      "Northwest artists. \r\n"+
      "\r\n"+
      "Musicfest NW September 6th-8th\r\n"+
      "In September, over 250 bands featuring all music genres perform \r\n"+
      "at various places around Portland. \r\n";

      tp.setText(t);
      StyledDocument doc = tp.getStyledDocument();
      SimpleAttributeSet sas = new SimpleAttributeSet();
      StyleConstants.setFontFamily(sas, "Times New Roman");
      StyleConstants.setFontSize(sas, 15);
      doc.setCharacterAttributes(0, doc.getLength(), sas, true);
      tp.setDocument(doc);
      getContentPane().add(tp);
      setSize(600,600);
      setVisible(true);


      try {
      Thread.sleep(1000);
      JOptionPane.showMessageDialog(this, tp.modelToView(doc.getLength()));
      } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }


      public static void main(String[] args){
      new TestModelToView();
      }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      No work around at this time

            peterz Peter Zhelezniakov
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: