KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > SAnchor


1 /*
2  * $Id: SAnchor.java,v 1.8 2005/01/31 10:44:39 oliverscheck Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings;
15
16 import org.wings.plaf.AnchorCG;
17
18 import java.net.URL JavaDoc;
19
20 /**
21  * Creates a 'normal'
22  * <a HREF=&quothttp://whatever/&quot>...</a>
23  * HTML link around some components that are stored in the container.
24  *
25  * @author <a HREF="mailto:H.Zeller@acm.org">Henner Zeller</a>
26  * @version $Revision: 1.8 $
27  */

28 public class SAnchor extends SContainer {
29
30     /**
31      * the URL to link to.
32      */

33     protected SimpleURL url;
34
35     /**
36      * the target frame/window.
37      */

38     protected String JavaDoc target;
39
40     /**
41      * creates an anchor with emtpy URL and target.
42      */

43     public SAnchor() {
44         this((SimpleURL) null, null);
45     }
46
47     /**
48      * create an anchor that points to the URL url.
49      *
50      * @param url the url to point to.
51      */

52     public SAnchor(String JavaDoc url) {
53         this(url, null);
54     }
55
56     /**
57      * creates an anchor that points to the URL and is openend
58      * in the frame or window named target.
59      *
60      * @param url the url to link to.
61      * @param target the target window or frame.
62      */

63     public SAnchor(String JavaDoc url, String JavaDoc target) {
64         setURL(url);
65         setTarget(target);
66     }
67
68     /**
69      * creates an anchor that points to the URL and is openend
70      * in the frame or window named target.
71      *
72      * @param url the url to link to.
73      * @param target the target window or frame.
74      */

75     public SAnchor(SimpleURL url, String JavaDoc target) {
76         setURL(url);
77         setTarget(target);
78     }
79
80     /**
81      * set the url this anchor points to.
82      *
83      * @param ref the url.
84      */

85     public void setURL(URL JavaDoc ref) {
86         if (ref != null) {
87             setURL(ref.toString());
88         } else {
89             setURL((SimpleURL) null);
90         }
91     }
92
93     /**
94      * set the url this anchor points to.
95      *
96      * @param r the url.
97      */

98     public void setURL(SimpleURL r) {
99         SimpleURL oldURL = url;
100         url = r;
101         if (url == null && oldURL != null
102                 || (url != null && !url.equals(oldURL))) {
103             reload();
104         }
105     }
106
107     /**
108      * set the url this anchor points to.
109      *
110      * @param url the url.
111      */

112     public void setURL(String JavaDoc url) {
113         setURL(new SimpleURL(url));
114     }
115
116     /**
117      * set the name of the target frame/window.
118      */

119     public void setTarget(String JavaDoc t) {
120         target = t;
121     }
122
123     /**
124      * get the name of the target frame/window.
125      */

126     public String JavaDoc getTarget() {
127         return target;
128     }
129
130     public SimpleURL getURL() {
131         return url;
132     }
133
134     public void setCG(AnchorCG cg) {
135         super.setCG(cg);
136     }
137 }
138
139
140
Popular Tags