< prev index next >

src/java.desktop/share/classes/javax/swing/event/HyperlinkEvent.java

Print this page




  23  * questions.
  24  */
  25 package javax.swing.event;
  26 
  27 import java.awt.event.InputEvent;
  28 import java.util.EventObject;
  29 import java.net.URL;
  30 import javax.swing.text.Element;
  31 
  32 
  33 /**
  34  * HyperlinkEvent is used to notify interested parties that
  35  * something has happened with respect to a hypertext link.
  36  * <p>
  37  * <strong>Warning:</strong>
  38  * Serialized objects of this class will not be compatible with
  39  * future Swing releases. The current serialization support is
  40  * appropriate for short term storage or RMI between applications running
  41  * the same version of Swing.  As of 1.4, support for long term storage
  42  * of all JavaBeans&trade;
  43  * has been added to the <code>java.beans</code> package.
  44  * Please see {@link java.beans.XMLEncoder}.
  45  *
  46  * @author  Timothy Prinzing
  47  */
  48 @SuppressWarnings("serial") // Same-version serialization only
  49 public class HyperlinkEvent extends EventObject {
  50 
  51     /**
  52      * Creates a new object representing a hypertext link event.
  53      * The other constructor is preferred, as it provides more
  54      * information if a URL could not be formed.  This constructor
  55      * is primarily for backward compatibility.
  56      *
  57      * @param source the object responsible for the event
  58      * @param type the event type
  59      * @param u the affected URL
  60      */
  61     public HyperlinkEvent(Object source, EventType type, URL u) {
  62         this(source, type, u, null);
  63     }


 142      * This may be useful if a URL can't be formed
 143      * from the description, in which case the associated
 144      * URL would be null.
 145      *
 146      * @return the description of this link as a {@code String}
 147      */
 148     public String getDescription() {
 149         return desc;
 150     }
 151 
 152     /**
 153      * Gets the URL that the link refers to.
 154      *
 155      * @return the URL
 156      */
 157     public URL getURL() {
 158         return u;
 159     }
 160 
 161     /**
 162      * Returns the <code>Element</code> that corresponds to the source of the
 163      * event. This will typically be an <code>Element</code> representing
 164      * an anchor. If a constructor that is used that does not specify a source
 165      * <code>Element</code>, or null was specified as the source
 166      * <code>Element</code>, this will return null.
 167      *
 168      * @return Element indicating source of event, or null
 169      * @since 1.4
 170      */
 171     public Element getSourceElement() {
 172         return sourceElement;
 173     }
 174 
 175     /**
 176      * Returns the {@code InputEvent} that triggered the hyperlink event.
 177      * This will typically be a {@code MouseEvent}.  If a constructor is used
 178      * that does not specify an {@code InputEvent}, or @{code null}
 179      * was specified as the {@code InputEvent}, this returns {@code null}.
 180      *
 181      * @return  InputEvent that triggered the hyperlink event, or null
 182      * @since 1.7
 183      */
 184     public InputEvent getInputEvent() {
 185         return inputEvent;
 186     }




  23  * questions.
  24  */
  25 package javax.swing.event;
  26 
  27 import java.awt.event.InputEvent;
  28 import java.util.EventObject;
  29 import java.net.URL;
  30 import javax.swing.text.Element;
  31 
  32 
  33 /**
  34  * HyperlinkEvent is used to notify interested parties that
  35  * something has happened with respect to a hypertext link.
  36  * <p>
  37  * <strong>Warning:</strong>
  38  * Serialized objects of this class will not be compatible with
  39  * future Swing releases. The current serialization support is
  40  * appropriate for short term storage or RMI between applications running
  41  * the same version of Swing.  As of 1.4, support for long term storage
  42  * of all JavaBeans&trade;
  43  * has been added to the {@code java.beans} package.
  44  * Please see {@link java.beans.XMLEncoder}.
  45  *
  46  * @author  Timothy Prinzing
  47  */
  48 @SuppressWarnings("serial") // Same-version serialization only
  49 public class HyperlinkEvent extends EventObject {
  50 
  51     /**
  52      * Creates a new object representing a hypertext link event.
  53      * The other constructor is preferred, as it provides more
  54      * information if a URL could not be formed.  This constructor
  55      * is primarily for backward compatibility.
  56      *
  57      * @param source the object responsible for the event
  58      * @param type the event type
  59      * @param u the affected URL
  60      */
  61     public HyperlinkEvent(Object source, EventType type, URL u) {
  62         this(source, type, u, null);
  63     }


 142      * This may be useful if a URL can't be formed
 143      * from the description, in which case the associated
 144      * URL would be null.
 145      *
 146      * @return the description of this link as a {@code String}
 147      */
 148     public String getDescription() {
 149         return desc;
 150     }
 151 
 152     /**
 153      * Gets the URL that the link refers to.
 154      *
 155      * @return the URL
 156      */
 157     public URL getURL() {
 158         return u;
 159     }
 160 
 161     /**
 162      * Returns the {@code Element} that corresponds to the source of the
 163      * event. This will typically be an {@code Element} representing
 164      * an anchor. If a constructor that is used that does not specify a source
 165      * {@code Element}, or null was specified as the source
 166      * {@code Element}, this will return null.
 167      *
 168      * @return Element indicating source of event, or null
 169      * @since 1.4
 170      */
 171     public Element getSourceElement() {
 172         return sourceElement;
 173     }
 174 
 175     /**
 176      * Returns the {@code InputEvent} that triggered the hyperlink event.
 177      * This will typically be a {@code MouseEvent}.  If a constructor is used
 178      * that does not specify an {@code InputEvent}, or @{code null}
 179      * was specified as the {@code InputEvent}, this returns {@code null}.
 180      *
 181      * @return  InputEvent that triggered the hyperlink event, or null
 182      * @since 1.7
 183      */
 184     public InputEvent getInputEvent() {
 185         return inputEvent;
 186     }


< prev index next >