1 /*
2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package javax.swing.text.html;
26 
27 import java.awt.event.InputEvent;
28 import javax.swing.text.*;
29 import javax.swing.event.HyperlinkEvent;
30 import java.net.URL;
31 
32 /**
33  * HTMLFrameHyperlinkEvent is used to notify interested
34  * parties that link was activated in a frame.
35  *
36  * @author Sunita Mani
37  */
38 @SuppressWarnings("serial") // Superclass is not serializable across versions
39 public class HTMLFrameHyperlinkEvent extends HyperlinkEvent {
40 
41     /**
42      * Creates a new object representing a html frame
43      * hypertext link event.
44      *
45      * @param source the object responsible for the event
46      * @param type the event type
47      * @param targetURL the affected URL
48      * @param targetFrame the Frame to display the document in
49      */
HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String targetFrame)50     public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL,
51                                    String targetFrame) {
52         super(source, type, targetURL);
53         this.targetFrame = targetFrame;
54     }
55 
56 
57     /**
58      * Creates a new object representing a hypertext link event.
59      *
60      * @param source the object responsible for the event
61      * @param type the event type
62      * @param targetURL the affected URL
63      * @param desc a description
64      * @param targetFrame the Frame to display the document in
65      */
HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc, String targetFrame)66     public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc,
67                                    String targetFrame) {
68         super(source, type, targetURL, desc);
69         this.targetFrame = targetFrame;
70     }
71 
72     /**
73      * Creates a new object representing a hypertext link event.
74      *
75      * @param source the object responsible for the event
76      * @param type the event type
77      * @param targetURL the affected URL
78      * @param sourceElement the element that corresponds to the source
79      *                      of the event
80      * @param targetFrame the Frame to display the document in
81      */
HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, Element sourceElement, String targetFrame)82     public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL,
83                                    Element sourceElement, String targetFrame) {
84         super(source, type, targetURL, null, sourceElement);
85         this.targetFrame = targetFrame;
86     }
87 
88 
89     /**
90      * Creates a new object representing a hypertext link event.
91      *
92      * @param source the object responsible for the event
93      * @param type the event type
94      * @param targetURL the affected URL
95      * @param desc a description
96      * @param sourceElement the element that corresponds to the source
97      *                      of the event
98      * @param targetFrame the Frame to display the document in
99      */
HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc, Element sourceElement, String targetFrame)100     public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc,
101                                    Element sourceElement, String targetFrame) {
102         super(source, type, targetURL, desc, sourceElement);
103         this.targetFrame = targetFrame;
104     }
105 
106     /**
107      * Creates a new object representing a hypertext link event.
108      *
109      * @param source the object responsible for the event
110      * @param type the event type
111      * @param targetURL the affected URL
112      * @param desc a description
113      * @param sourceElement the element that corresponds to the source
114      *                      of the event
115      * @param inputEvent  InputEvent that triggered the hyperlink event
116      * @param targetFrame the Frame to display the document in
117      * @since 1.7
118      */
HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL, String desc, Element sourceElement, InputEvent inputEvent, String targetFrame)119     public HTMLFrameHyperlinkEvent(Object source, EventType type, URL targetURL,
120                                    String desc, Element sourceElement,
121                                    InputEvent inputEvent, String targetFrame) {
122         super(source, type, targetURL, desc, sourceElement, inputEvent);
123         this.targetFrame = targetFrame;
124     }
125 
126     /**
127      * returns the target for the link.
128      *
129      * @return the target for the link
130      */
getTarget()131     public String getTarget() {
132         return targetFrame;
133     }
134 
135     private String targetFrame;
136 }
137