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

Editing HTML in JTextPane does not work with end of lines

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta2
    • generic
    • generic

      Name: dk106046 Date: 01-21-2002

      The Testcase below appears to be resolved in the Merlin build I used (1.4.0 b92). However, per IBM interest in this bug, an additional Test Case has been provided & uploaded as an attachment (Test.jar). Running this testcase, the bug appears to resurface.
        
      Name: skT88420 Date: 01/24/2000


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


      Creating an HTML text from scratch in a JtextPane is working well, but
      editing an existing text is a real nightmare.
      As soon as you set a text by the JtextPane.setText() method and if a
      paragraph has an attribute (like « align=center » for example), the editing
      operation becomes weird.
      If you put the caret on the beginning of the first blank line after this
      text, and try to delete previous characters with "backspace" key, then you
      will see that characters are deleted but the caret stays on the blank line.
      This is definately not comfortable for the end user.

      The following simple code shows the bug :


      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class MiniHTMLEditor extends JApplet
      {
      public void init()
      {
      JTextPane textPane;
      String text = "<p align=center>Please put the caret on the
      beginning of the <b>first blank line</b> after this text, and try to <b>delete
      previous characters</b> with \"backspace\" key. You will see that characters
      are deleted but the caret stays on the blank line.</p>";

      textPane = new JTextPane();
      textPane.setContentType("text/html");
      getContentPane().add(textPane);

      textPane.setText(text);
      }
                                   
      public static void main(String[] args)
      {
      MiniHTMLEditor editor = new MiniHTMLEditor();
      editor.init();

          JFrame f = new JFrame();
          f.getContentPane().add("Center", editor);
          f.pack();
          f.setSize(new Dimension(400,300));
          f.show();
      }
      }
      (Review ID: 100291)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: