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

Presetting JEditorPane with static text adds extra paragraph (w/HTMLEditorKit)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta2
    • x86
    • windows_nt, windows_2000



      Name: krT82822 Date: 03/05/2000


      5 Mar 2000, eval1127@eng -- looked extensively for a dupe of this...couldn't find one. Also tried doing explicit pack on the enclosing JFrame, to see if this would have
      any effect (no).

      java version "1.3.0rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
      Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)


      1. Compile and run the code below
      2. When the window shows up, put click on the word 'test' so that the caret is
      placed on the same line as the text.
      3. Press the arrow down key.

      Expected outcome:
        the caret stays on the same line, since there shouldn't be anything else in
      the field.

      Actual outcome:
        the caret moves down by one line

      import java.awt.*;
      import java.util.*;
      import javax.swing.*;
      import javax.swing.text.*;
      import javax.swing.text.html.*;

      public class test extends JPanel
      {
         private JEditorPane html1;

         public static void main( String args[] )
         {
            JFrame frame = new JFrame("Test");
            frame.setContentPane( new test() );
            frame.setBounds(100,100,100,100);
            frame.show();
         }

         public test()
         {
            html1 = new JEditorPane();
            html1.setEditorKit( new HTMLEditorKit() );
            html1.setText("test");
            add( html1, BorderLayout.CENTER );

            StyledDocument doc = (StyledDocument)html1.getDocument();
         }
      }

      dmb
      (Review ID: 102062)
      ======================================================================

      Name: ks88420 Date: 08/22/2000


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

      There appears to be some problems with the HTML Editor Kit in JRE version 1.3.0
      on windows NT and 95/98.

      We have set up a standard HTML Editor Kit in the same way as below and are
      observing strange behavior as described below.

      <pre>
      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();
        }
      }
      </pre>


        To reproduce the problems perform the following...

      (1) Press the bullet button now put the caret to the right of the newly created
      bullet and type some text. This text is being entered on the line below where
      the bullet appears.

      (2) Clear everything from the screen and press the bullet button again put the
      caret to the right of this newly created bullet press the back arrow once. Now
      type some text and the text will appear on the right line but the text is
      center aligned, standard behavoiur indicates that it should be left aligned.

      (3) Put the caret on the line below this bullet and type some text. Now
      backspace all of this text and keep pressing backspace. The text on the line
      with the bullet is actually being backspaced but the caret is staying on the
      line below.

      (4) The up and down arrows do not move the caret up or down when the caret runs
      into a bullet or is within a bullet.

      I have had a look at the code and believe most of these problems are related to
      the editor kit caret location not being placed inside the tags or handling the
      "li" and "ul" tags correctly.

      Any workarounds for this problem would be greatly appreciated as we need to get
      this control working correctly ASAP.

      Matthew Kuter
      ###@###.###
      (Review ID: 106819)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: