JEditorPane s fire a type of event called a
HyperlinkEvent. Typically, this event is fired
when the user clicks on a hyperlink in the currently displayed document;
the program normally responds by loading a new page. To support this
event type, a related event class and listener interface are available
interface (found in
javax.swing.event) defines a single method,
used to respond to hyperlink activations:
Called to indicate that a hyperlink request has been made.
Typical implementations of this method obtain the new
URL from the event and call
setPage( ) on the associated
JEditorPane. See the
JEditorPane example earlier in the
chapter to learn how this method can be used.
class (found in
describes a hyperlink request.
HyperlinkEvent defines the
properties shown in Table
URL property contains a
java.net.URL object that can be used to
retrieve URL content represented by the event. The
description property allows a description
of the link (typically, the text of the hyperlink) to be supplied.
This can be useful when the
null, such as when
the hyperlink can’t be parsed well enough to create a
URL object. The
eventType property defines the type of
event that has occurred.
Table 23-9. HyperlinkEvent properties
Data type ...