APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.event

public Class HyperlinkEvent

extends EventObject
Class Inheritance
Known Direct Subclasses
javax.swing.text.html.HTMLFrameHyperlinkEvent
Annotations
@SuppressWarnings:serial
Imports
java.awt.event.InputEvent, java.util.EventObject, java.net.URL, javax.swing.text.Element

HyperlinkEvent is used to notify interested parties that something has happened with respect to a hypertext link.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Timothy Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
HyperlinkEvent.EventType

Defines the ENTERED, EXITED, and ACTIVATED event types, along with their string representations, returned by toString().

Field Summary

Modifier and TypeField and Description
private String
private InputEvent
private Element
private HyperlinkEvent.EventType
private URL
u

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
HyperlinkEvent(Object
the object responsible for the event
source
,
HyperlinkEvent.EventType
the event type
type
,
URL
the affected URL
u
)

Creates a new object representing a hypertext link event.

public
HyperlinkEvent(Object
the object responsible for the event
source
,
HyperlinkEvent.EventType
the event type
type
,
URL
the affected URL. This may be null if a valid URL could not be created.
u
,
String
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.
desc
)

Creates a new object representing a hypertext link event.

public
HyperlinkEvent(Object
the object responsible for the event
source
,
HyperlinkEvent.EventType
the event type
type
,
URL
the affected URL. This may be null if a valid URL could not be created.
u
,
String
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.
desc
,
Element
Element in the Document representing the anchor
sourceElement
)

Creates a new object representing a hypertext link event.

public
HyperlinkEvent(Object
the object responsible for the event
source
,
HyperlinkEvent.EventType
the event type
type
,
URL
the affected URL. This may be null if a valid URL could not be created.
u
,
String
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.
desc
,
Element
Element in the Document representing the anchor
sourceElement
,
InputEvent
InputEvent that triggered the hyperlink event
inputEvent
)

Creates a new object representing a hypertext link event.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the description of this link as a String
getDescription
()

Get the description of the link as a string.

public HyperlinkEvent.EventType

Returns:

the type
getEventType
()

Gets the type of event.

public InputEvent

Returns:

InputEvent that triggered the hyperlink event, or null
getInputEvent
()

Returns the InputEvent that triggered the hyperlink event.

public Element

Returns:

Element indicating source of event, or null
getSourceElement
()

Returns the Element that corresponds to the source of the event.

public URL

Returns:

the URL
getURL
()

Gets the URL that the link refers to.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

descback to summary
private String desc
inputEventback to summary
private InputEvent inputEvent
sourceElementback to summary
private Element sourceElement
typeback to summary
private HyperlinkEvent.EventType type
uback to summary
private URL u

Constructor Detail

HyperlinkEventback to summary
public HyperlinkEvent(Object source, HyperlinkEvent.EventType type, URL u)

Creates a new object representing a hypertext link event. The other constructor is preferred, as it provides more information if a URL could not be formed. This constructor is primarily for backward compatibility.

Parameters
source:Object

the object responsible for the event

type:HyperlinkEvent.EventType

the event type

u:URL

the affected URL

HyperlinkEventback to summary
public HyperlinkEvent(Object source, HyperlinkEvent.EventType type, URL u, String desc)

Creates a new object representing a hypertext link event.

Parameters
source:Object

the object responsible for the event

type:HyperlinkEvent.EventType

the event type

u:URL

the affected URL. This may be null if a valid URL could not be created.

desc:String

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.

HyperlinkEventback to summary
public HyperlinkEvent(Object source, HyperlinkEvent.EventType type, URL u, String desc, Element sourceElement)

Creates a new object representing a hypertext link event.

Parameters
source:Object

the object responsible for the event

type:HyperlinkEvent.EventType

the event type

u:URL

the affected URL. This may be null if a valid URL could not be created.

desc:String

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.

sourceElement:Element

Element in the Document representing the anchor

Since
1.4
HyperlinkEventback to summary
public HyperlinkEvent(Object source, HyperlinkEvent.EventType type, URL u, String desc, Element sourceElement, InputEvent inputEvent)

Creates a new object representing a hypertext link event.

Parameters
source:Object

the object responsible for the event

type:HyperlinkEvent.EventType

the event type

u:URL

the affected URL. This may be null if a valid URL could not be created.

desc:String

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.

sourceElement:Element

Element in the Document representing the anchor

inputEvent:InputEvent

InputEvent that triggered the hyperlink event

Since
1.7

Method Detail

getDescriptionback to summary
public String getDescription()

Get the description of the link as a string. This may be useful if a URL can't be formed from the description, in which case the associated URL would be null.

Returns:String

the description of this link as a String

getEventTypeback to summary
public HyperlinkEvent.EventType getEventType()

Gets the type of event.

Returns:HyperlinkEvent.EventType

the type

getInputEventback to summary
public InputEvent getInputEvent()

Returns the InputEvent that triggered the hyperlink event. This will typically be a MouseEvent. If a constructor is used that does not specify an InputEvent, or null was specified as the InputEvent, this returns null.

Returns:InputEvent

InputEvent that triggered the hyperlink event, or null

Since
1.7
getSourceElementback to summary
public Element getSourceElement()

Returns the Element that corresponds to the source of the event. This will typically be an Element representing an anchor. If a constructor that is used that does not specify a source Element, or null was specified as the source Element, this will return null.

Returns:Element

Element indicating source of event, or null

Since
1.4
getURLback to summary
public URL getURL()

Gets the URL that the link refers to.

Returns:URL

the URL

javax.swing.event back to summary

public final Class HyperlinkEvent.EventType

extends Object
Class Inheritance

Defines the ENTERED, EXITED, and ACTIVATED event types, along with their string representations, returned by toString().

Field Summary

Modifier and TypeField and Description
public static final HyperlinkEvent.EventType
ACTIVATED

Activated type.

public static final HyperlinkEvent.EventType
ENTERED

Entered type.

public static final HyperlinkEvent.EventType
EXITED

Exited type.

private String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the string
toString
()

Overrides java.lang.Object.toString.

Converts the type to a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ACTIVATEDback to summary
public static final HyperlinkEvent.EventType ACTIVATED

Activated type.

ENTEREDback to summary
public static final HyperlinkEvent.EventType ENTERED

Entered type.

EXITEDback to summary
public static final HyperlinkEvent.EventType EXITED

Exited type.

typeStringback to summary
private String typeString

Constructor Detail

EventTypeback to summary
private EventType(String s)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Converts the type to a string.

Returns:String

the string