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

JTextPane wrapping within words in Java 7 (word wrapping broken)

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_03"
      Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
      Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows version 6.1.7601

      A DESCRIPTION OF THE PROBLEM :
      When multiple styles are available on one line of text, wrapping does not occur at word boundaries but within words.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a JTextPane.
      2. Insert some text, use multiple styles.
      3. Type in some text at the start of the document (you must type *before* the style change) .

      Use the demo provided below to exercise this problem, or the Stylepad demo that comes with the JDK.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When the line is full, the word that can't be displayed entirely on the line is shifted to the next line.
      ACTUAL -
      When the line is full, the word that can't be displayed entirely on the line is broken, the first part staying on the line and the remaining being shifted to the next line.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JTextPane;
      import javax.swing.text.Document;
      import javax.swing.text.SimpleAttributeSet;
      import javax.swing.text.StyleConstants;

      public class JTextPaneWordWrapBug {
          
          public static void main(String args[]) throws Exception {
              SimpleAttributeSet sas = new SimpleAttributeSet();
              StyleConstants.setBold(sas, true);
              
              JTextPane pane = new JTextPane();
              Document document = pane.getDocument();
              document.insertString(0, "Lorem ", null);
              document.insertString(document.getLength(), "ipsum", sas);
              document.insertString(document.getLength(), " dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", null);
                      
              JFrame frame = new JFrame();
              frame.add(pane);
              frame.setBounds(100,100,200,200);
              frame.setVisible(true);
              return;
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            ssadetsky Semyon Sadetsky (Inactive)
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: