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

JEditorPane hyperlinks activate only when mouse is motionless

XMLWordPrintable

    • generic, x86
    • generic, windows_2000

      Name: bsC130419 Date: 08/20/2001


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


      In a JEditorPane displaying an HTML page with hyperlinks, the hyperlinks will
      only fire a hyperlinkUpdate (with an HyperlinkEvent.EventType.ACTIVATED event
      type) if the mouse does not move between the button press and the button
      release. This becomes a usability issue when (as we had last week) elderly or
      non-computer-friendly people have to use the application. They may either not
      understand that holding the mouse still is an issue, or may be unable to hold
      the mouse still effectively when clicking.

      This should possibly be marked an enhancement, not a bug. I think it is a bug,
      since it marks a significant difference between the JEditorPane displaying HTML
      and a standard web browser (which has flexibility when responding to hyperlink
      clicks).

      Here is a simple program that can be used to demonstrate the issue:

      <code>

      import javax.swing.JEditorPane;
      import javax.swing.JFrame;
      import javax.swing.event.HyperlinkListener;
      import javax.swing.event.HyperlinkEvent;

      public class Hyperlink implements HyperlinkListener {

      public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      System.out.println("Click registered");
      }
      } // end hyperlinkUpdate(HyperlinkEvent)

      public static void main(String[] args) {
      JEditorPane pane = new JEditorPane();
      pane.setContentType("text/html");
      pane.setEditable(false);
      pane.setText("<html><body><h2>Please click " +
      "<a href=\"http://java.sun.com\">here</a>, " +
      "thanks!</h2></body></html>");
      pane.addHyperlinkListener(new Hyperlink());

      JFrame frame = new JFrame("Hyperlink test");
      frame.getContentPane().add(pane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setSize(300, 150);
      frame.show();
      } // end main(String[])
      } // end class Hyperlink

      Note that the "Click registered" string is only printed if the hyperlink is
      clicked on when the mouse is motionless. Compare to standard web browsers (I
      tested on IE 5.5 and Mozilla) which allow a certain amount of drag to occur
      (before switching to drag and drop or highlight mode).
      (Review ID: 130337)
      ======================================================================

            Unassigned Unassigned
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: