javax.swing.event
Class HyperlinkEvent

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject 
      extended by javax.swing.event.HyperlinkEvent
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable
Direct Known Subclasses:
HTMLFrameHyperlinkEvent sample code for javax.swing.text.html.HTMLFrameHyperlinkEvent definition code for javax.swing.text.html.HTMLFrameHyperlinkEvent

public class HyperlinkEvent
extends EventObject sample code for java.util.EventObject definition code for java.util.EventObject

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 JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Serialized Form

Nested Class Summary
static class HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType
          Defines the ENTERED, EXITED, and ACTIVATED event types, along with their string representations, returned by toString().
 
Field Summary
 
Fields inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
source sample code for java.util.EventObject.source definition code for java.util.EventObject.source
 
Constructor Summary
HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL) definition code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL) (Object sample code for java.lang.Object definition code for java.lang.Object  source, HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type, URL sample code for java.net.URL definition code for java.net.URL  u)
          Creates a new object representing a hypertext link event.
HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String) definition code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String) (Object sample code for java.lang.Object definition code for java.lang.Object  source, HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type, URL sample code for java.net.URL definition code for java.net.URL  u, String sample code for java.lang.String definition code for java.lang.String  desc)
          Creates a new object representing a hypertext link event.
HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String, javax.swing.text.Element) definition code for javax.swing.event.HyperlinkEvent.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String, javax.swing.text.Element) (Object sample code for java.lang.Object definition code for java.lang.Object  source, HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type, URL sample code for java.net.URL definition code for java.net.URL  u, String sample code for java.lang.String definition code for java.lang.String  desc, Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  sourceElement)
          Creates a new object representing a hypertext link event.
 
Method Summary
 String sample code for java.lang.String definition code for java.lang.String getDescription sample code for javax.swing.event.HyperlinkEvent.getDescription() definition code for javax.swing.event.HyperlinkEvent.getDescription() ()
          Get the description of the link as a string.
 HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType getEventType sample code for javax.swing.event.HyperlinkEvent.getEventType() definition code for javax.swing.event.HyperlinkEvent.getEventType() ()
          Gets the type of event.
 Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element getSourceElement sample code for javax.swing.event.HyperlinkEvent.getSourceElement() definition code for javax.swing.event.HyperlinkEvent.getSourceElement() ()
          Returns the Element that corresponds to the source of the event.
 URL sample code for java.net.URL definition code for java.net.URL getURL sample code for javax.swing.event.HyperlinkEvent.getURL() definition code for javax.swing.event.HyperlinkEvent.getURL() ()
          Gets the URL that the link refers to.
 
Methods inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
getSource sample code for java.util.EventObject.getSource() definition code for java.util.EventObject.getSource() , toString sample code for java.util.EventObject.toString() definition code for java.util.EventObject.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL) definition code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL)

public HyperlinkEvent(Object sample code for java.lang.Object definition code for java.lang.Object  source,
                      HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type,
                      URL sample code for java.net.URL definition code for java.net.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 - the object responsible for the event
type - the event type
u - the affected URL

HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String) definition code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String)

public HyperlinkEvent(Object sample code for java.lang.Object definition code for java.lang.Object  source,
                      HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type,
                      URL sample code for java.net.URL definition code for java.net.URL  u,
                      String sample code for java.lang.String definition code for java.lang.String  desc)
Creates a new object representing a hypertext link event.

Parameters:
source - the object responsible for the event
type - the event type
u - the affected URL. This may be null if a valid URL could not be created.
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.

HyperlinkEvent sample code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String, javax.swing.text.Element) definition code for javax.swing.event.HyperlinkEvent(java.lang.Object, javax.swing.event.HyperlinkEvent.EventType, java.net.URL, java.lang.String, javax.swing.text.Element)

public HyperlinkEvent(Object sample code for java.lang.Object definition code for java.lang.Object  source,
                      HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  type,
                      URL sample code for java.net.URL definition code for java.net.URL  u,
                      String sample code for java.lang.String definition code for java.lang.String  desc,
                      Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  sourceElement)
Creates a new object representing a hypertext link event.

Parameters:
source - the object responsible for the event
type - the event type
u - the affected URL. This may be null if a valid URL could not be created.
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.
sourceElement - Element in the Document representing the anchor
Since:
1.4
Method Detail

getEventType sample code for javax.swing.event.HyperlinkEvent.getEventType() definition code for javax.swing.event.HyperlinkEvent.getEventType()

public HyperlinkEvent.EventType sample code for javax.swing.event.HyperlinkEvent.EventType definition code for javax.swing.event.HyperlinkEvent.EventType  getEventType()
Gets the type of event.

Returns:
the type

getDescription sample code for javax.swing.event.HyperlinkEvent.getDescription() definition code for javax.swing.event.HyperlinkEvent.getDescription()

public String sample code for java.lang.String definition code for java.lang.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.


getURL sample code for javax.swing.event.HyperlinkEvent.getURL() definition code for javax.swing.event.HyperlinkEvent.getURL()

public URL sample code for java.net.URL definition code for java.net.URL  getURL()
Gets the URL that the link refers to.

Returns:
the URL

getSourceElement sample code for javax.swing.event.HyperlinkEvent.getSourceElement() definition code for javax.swing.event.HyperlinkEvent.getSourceElement()

public Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  getSourceElement()
Returns the Element that corresponds to the source of the event. This will typically be an Element representing an anchor. If a constructur that is used that does not specify a source Element, or null was specified as the source Element, this will return null.

Returns:
Element indicating source of event, or null
Since:
1.4