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

setFirstLineIndent cause sizes to be wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • None
    • 6u1
    • client-libs

      J2SE Version (please include all output from java -version flag):
      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)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Microsoft Windows XP [Version 5.1.2600]

      Bug Description:
      setFirstLineIndent causes sizes to be wrong

      When I run the following code I notice two (probably related) problems:
      1) The cursor is twice as high as it should be
      2) The text does not fit in the allocated area

      import static javax.swing.JFrame.*;
      import javax.swing.*;
      import javax.swing.text.*;

      public class Test {
        public static void main(String[] args) {
          try {
            JEditorPane pane = new JEditorPane("text/html", "");
            SimpleAttributeSet attributeSet = new SimpleAttributeSet();
            StyleConstants.setFirstLineIndent(attributeSet, 36);
            pane.getDocument().insertString(0, "Sample Text\nSample Text", attributeSet);
            JPanel panel = new JPanel();
            panel.add(pane);
            JFrame frame = new JFrame();
            frame.add(panel);
            frame.pack();
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setVisible(true);
          }
          catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }

            peterz Peter Zhelezniakov
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: