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

Cursor is not going to end of line in JEditorPane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6u4
    • client-libs
    • sparc
    • solaris_2.5.1

      OPERATING SYSTEM(S):
      All

      FULL JDK VERSION(S):
      Java version "1.6.0_04"
      Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

      STEPS TO REPRODUCE:

      1.Install Sun jdk 1.6.0_04.Set PATH to java.
      2.To test compile and run the following testcase.
      4.Select "Swing text components" .
      5.Put the cursor in the 1st line of "JEditorPane1".
      7.Press "Home" button in the keyboard.(It will move the cursor before "B".
      8.Now press "END" button.

      Observed result:
      Cursor will not move to the end of line. It will move the cursor one
      character before the last character.

      Expected result:
      Cursor should be moved to the end of the character in the corresponding
      line.


      TESTCASE:

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

      public class SwingComponenttest {

          static JFrame textComponentsFrame = null;
          public static void main(String[] args) {

              textComponentsFrame = new JFrame(" Swing Text Components : " );
              Container container = textComponentsFrame.getContentPane();
              container.add(new dndTextComponentsPanel().dndJEditorPane());
              textComponentsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              textComponentsFrame.pack();
              textComponentsFrame.setVisible(true);
          }
      }

      class dndTextComponentsPanel extends JPanel {

          final String nurseryText1 = "Baa, baa, black sheep, Have you any wool? Yes sir, yes sir, Three bags full;";

          private JEditorPane editorPane1 = null;

          private JScrollPane editorScrollPane1 = null;

          public JPanel dndJEditorPane() {

              JPanel epPanel = null;
              editorPane1 = new JEditorPane("text/plain", nurseryText1);
              editorScrollPane1 = new JScrollPane(editorPane1);
              editorScrollPane1.setBorder(BorderFactory.createTitledBorder("JEditorPane 1"));

              // setup scroll panes
              editorScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              editorScrollPane1.setPreferredSize(new Dimension(200, 110));
              editorScrollPane1.setMinimumSize(new Dimension(10, 10));

              // enable dnd for components
              editorPane1.setDragEnabled(true);
              editorPane1.setVisible(true);
              editorPane1.setContentType("text/plain");
              editorPane1.setText(nurseryText1);

              epPanel = new JPanel();
              epPanel.setLayout(new BorderLayout());
              epPanel.add(editorScrollPane1, BorderLayout.NORTH);
              return epPanel;
          }

      }

            peterz Peter Zhelezniakov
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: