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

The java.awt.swing.JTextPane.replaceSelection(s) does not work properly

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.6
    • Verified



      Name: akC57697 Date: 12/04/97


      The java.awt.swing.JTextPane.replaceSelection(s) does not work properly
      with full selection.

      --------------8-<-------------------------------
      import java.awt.swing.JTextPane;
      import java.awt.swing.text.*;

      public class JTextPaneBug {
          public static void main(String s[]) {
          String s1="123456789";
            JTextPane c = new JTextPane();

            c.setText(s1); // Set the string.
            c.selectAll(); // Replace with
            c.replaceSelection(s1);// same string.
           
            System.exit(0);
         }
      }
      ------------->-8--------------------------------
      Output:
      (novo35 97): java JTextPaneBug
      java.lang.NullPointerException
      at java.awt.swing.text.DefaultStyledDocument$ElementBuffer.open(DefaultStyledDocument.java:1238)
      at java.awt.swing.text.DefaultStyledDocument$ElementBuffer.insertUpdate(DefaultStyledDocument.java:798)
      at java.awt.swing.text.DefaultStyledDocument$ElementBuffer.insert(DefaultStyledDocument.java:750)
      at java.awt.swing.text.DefaultStyledDocument.insertUpdate(DefaultStyledDocument.java:392)
      at java.awt.swing.text.AbstractDocument.insertString(AbstractDocument.java:243)
      at java.awt.swing.JTextPane.replaceSelection(JTextPane.java:157)
      at JTextPaneBug.main(JTextPaneBug.java:11)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: