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

HTMLEditorKit: InsertUnorderedList action behaves weird

    XMLWordPrintable

Details

    • 6.0
    • x86
    • windows_2000

    Backports

      Description

        FULL PRODUCT VERSION :
        1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105

        ADDITIONAL OS VERSION INFORMATION :
        Windows 2000 version 5.0 running on x86

        A DESCRIPTION OF THE PROBLEM :
        When you create a JEditorPane with a HTMLEditorKit and use the InsertUnorderedListItem action of the Editor kit to insert unordered lists, this items behave very weird. So it is not possible to produce more list items simply by hitting ENTER.
        When the caret is placed next to the first bullet and you hit BACKSPACE, you cannot delete the bullet, but you remove the paragraph before the item.
        When the caret is positioned below the last item, hitting BACKSPACE deletes the last character of the list item above, but does not move the caret to this position. The caret stays below the item.

        This seems to be a regression to JDK1.3, since I use the same example like in Bug# 4357975. The result is not exactly the same, but the behaviour is not correct.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile the example code and run it, then:

        1. Press the button. A bullet appears (is OK). Place the caret next to the bullet , or press SHIFT TAB to pass the focus to the editor pane. Enter some Text and press ENTER.

        2. Press Backspace several times until all entered characters is deleted. Press once more.

        3. Restart the example, press the button, place the caret next to the bullet and enter some text and press the button again.

        4. Restart or clrea all text, hit the button, place the caret next to the bullet and type some text. Move the caret to the paragraph below the list item (one line down) and hit BACKSAPCE

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        @1. After hitting Enter when the caret is in the paragraph of the bullet, you would expect a new bullet.

        @2. Pressing Backspace with the caret positioned at the leftmost position next to the bullet and with only one bullet in the list left should remove the bullet and the indent.

        @3. You would expect to get one more bullet.

        @4. You would expect the caret to move to the end of the list item above and to remove the last character.
        ACTUAL -
        @1: By hitting ENTER you get line breaks, but no next bullet. There is no way to create further bullets by simply hitting ENTER as you would expect from a text editing component, since this is the usual and well-known behaviour.

        @2. The bullet is not removed, but moves one line up. Even if there is no line left before the bullet, you cannot delete the bullet. You have to move the caret below the bullet and press backspace.

        @3: You get _two_ more bullets. Press the button once again, and then and the next times you press the button, you get one bullet. That seems to be inconsistent.

        @4: The last character of the list item above is removed, but the caret stays in the line below.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.*;
        import java.awt.event.*;
        import java.util.*;
        import javax.swing.*;
        import javax.swing.text.html.*;


        public class editorTest {
          JEditorPane edit = new JEditorPane();
          HTMLEditorKit htmleditorKit = new HTMLEditorKit();
          JButton btnBullet = new JButton();
          Action[] actions;
          Hashtable commands = new Hashtable();

          public editorTest() {
            JFrame frame = new JFrame();
            frame.getContentPane().setLayout(new BorderLayout());

            actions = htmleditorKit.getActions();
            for (int i=0; i<actions.length; i++){
              Action a = actions[i];
              commands.put(a.getValue(Action.NAME), a);
            }

            edit.setEditorKit(htmleditorKit);
            edit.setDocument(htmleditorKit.createDefaultDocument());
            btnBullet.setText("Bullet");
            btnBullet.addActionListener((Action)commands.get
        ("InsertUnorderedListItem"));
            frame.getContentPane().add(edit, BorderLayout.CENTER);
            frame.getContentPane().add(btnBullet, BorderLayout.SOUTH);

            frame.setSize(new Dimension(400,400));
            frame.setVisible(true);

            frame.addWindowListener(new WindowAdapter(){
               public void windowClosing(WindowEvent e)
                  {
                     System.exit(0);
                  }
            });

          }

          //Main method
          public static void main(String[] args) {
            new editorTest();
          }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Sorry, no workaround found, yet.
        I would need one very urgently, since I cannot comunicate this behaviour to my customers and tell them "this is quit normal, you simply have to get accustomed to this editor to behave not the way you would expect from any other text editing application".

        Release Regression From : 1.3
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                ndcosta Nelson Dcosta (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: