1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.swing;
17
18 import javax.swing.BorderFactory;
19 import javax.swing.border.Border;
20
21 import org.apache.commons.jelly.JellyTagException;
22 import org.apache.commons.jelly.MissingAttributeException;
23 import org.apache.commons.jelly.XMLOutput;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 /***
28 * Creates an empty border.
29 * The border will either be exported as a variable defined by the 'var' attribute
30 * or will be set on the parent widget's border property
31 *
32 * @author <a href="mailto:robert@bull-enterprises.com">Robert McIntosh</a>
33 * @version $Revision: 155420 $
34 */
35 public class EmptyBorderTag extends BorderTagSupport {
36
37 /*** The Log to which logging calls will be made. */
38 private static final Log log = LogFactory.getLog(EmptyBorderTag.class);
39
40 private int left = -1;
41 private int right = -1;
42 private int top = -1;
43 private int bottom = -1;
44
45
46
47 public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException {
48 if ( left == -1) {
49 throw new MissingAttributeException("left");
50 }
51 if ( right == -1) {
52 throw new MissingAttributeException("right");
53 }
54 if ( top == -1) {
55 throw new MissingAttributeException("top");
56 }
57 if ( bottom == -1) {
58 throw new MissingAttributeException("bottom");
59 }
60 super.doTag(output);
61 }
62
63
64
65 /***
66 * Sets the left inset
67 * @param left
68 */
69 public void setLeft( int left ) {
70 this.left = left;
71 }
72
73 /***
74 * Sets the right inset
75 * @param right
76 */
77 public void setRight( int right ) {
78 this.right = right;
79 }
80
81 /***
82 * Sets the top inset
83 * @param top
84 */
85 public void setTop( int top ) {
86 this.top = top;
87 }
88
89 /***
90 * Sets the bottom inset
91 * @param bottom
92 */
93 public void setBottom( int bottom ) {
94 this.bottom = bottom;
95 }
96
97 /***
98 * Factory method to create a new EmptyBorder instance.
99 */
100 protected Border createBorder() {
101 return BorderFactory.createEmptyBorder( top, left, bottom, right);
102 }
103
104 }