JDK-4182124 : HTMLEditorKit posting of ACTIVATE HyperlinkEvent()does not provide enough info
  • Type: Enhancement
  • Status: Resolved
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Affected Version: 1.2.0,1.3.0
  • OS: generic
  • CPU: generic
  • Submit Date: 1998-10-16
  • Updated Date: 2000-11-17
  • Resolved Date: 2000-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.0 betaResolved
Related Reports
Duplicate :  
Description

Name: clC74495			Date: 10/16/98


When using the JEditorPane with the HTMLEditorKit and given
an HTML link tag that looks like this:

<A HREF="http://www.klg.com" target="_new">http://www.klg.com</A>

it is not posssible to access the "target" since the
"getDescription()" merely returns the string that was used
to create the URL.  It seems to me that if one actually only
wanted the URL then they could call
"linkevent.getURL().toString()" which would leave you open to
provide the _whole_ tag information in the "description" field.
(Review ID: 40521)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
2004-06-14

EVALUATION The html package exposes a way for developers to determine when the mouse moves over a link via the HyperlinkEvent and HyperlinkListener classes. Often times developers need a way to extract information from the document when the HyperlinkListener is notified. There is currently no way for a developer to determine the position in the document a HyperlinkEvent represents. To aid this the following API will be added: javax.swing.event.HyperlinkEvent /** * Creates a new object representing a hypertext link event. * * @param source the object responsible for the event * @param type the event type * @param u the affected URL. This may be null if a valid URL * could not be created. * @param desc the description of the link. This may be useful * when attempting to form a URL resulted in a MalformedURLException. * The description provides the text used when attempting to form the * URL. * @param offset Start of the Element in the Document representing the * anchor * @since 1.4 */ public HyperlinkEvent(Object source, EventType type, URL u, String desc, int offset) { /** * Returns the offset into the Document of the start of the Element * containing the anchor. This may return -1 indicating the event is * not associated with a particular Element. * <p> * In most cases the offset will identify an Element representing an * anchor, but not always. For example, if an image with a map is * clicked on this will identify the element representing the image. * <p> * In a threaded environment where another thread * is modifying the Document it is possible for this offset to be * bogus. * * @return Element offset * @since 1.4 */ public int getElementOffset() { javax.swing.text.html.HTMLFrameHyperlinkEvent /** * Creates a new object representing a hypertext link event. * * @param source the object responsible for the event * @param type the event type * @param targetURL the affected URL * @param desc a description * @param targetFrame the Frame to display the document in * @param offset Start of the Element in the Document representing the * anchor * @since 1.4 */ public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc, String targetFrame, int offset) { scott.violet@eng 2000-03-06 We have decided to revamp this to use an Element as the position indicator instead of an offset. This way, if the Document changes, the Element will still be valid. The following will be added to javax.swing.event.HyperlinkEvent: /** * Creates a new object representing a hypertext link event. * * @param source the object responsible for the event * @param type the event type * @param u the affected URL. This may be null if a valid URL * could not be created. * @param desc the description of the link. This may be useful * when attempting to form a URL resulted in a MalformedURLException. * The description provides the text used when attempting to form the * URL. * @param sourceElement Element in the Document representing the * anchor * @since 1.4 */ public HyperlinkEvent(Object source, EventType type, URL u, String desc, Element sourceElement); /** * Returns the <code>Element</code> that corresponds to the source of the * event. This will typically be an <code>Element</code> representing * an anchor. If a constructur that is used that does not specify a source * <code>Element</code>, or null was specified as the source * <code>Element</code>, this will return null. * * @return Element indicating source of event, or null * @since 1.4 */ public Element getSourceElement(); And the following will be removed from javax.swing.text.html.HTMLFrameHyperlinkEvent: /** * returns the element that corresponds to the source of the * event. This would always be the leaf element whose * tag is HTML.Tag.FRAME. */ public Element getSourceElement(); As supers implementation will now be used. scott.violet@eng 2000-11-01
2000-11-01