KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > border > EmptyBorder


1 /*
2  * @(#)EmptyBorder.java 1.26 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.border;
8
9 import java.awt.Graphics JavaDoc;
10 import java.awt.Insets JavaDoc;
11 import java.awt.Rectangle JavaDoc;
12 import java.awt.Component JavaDoc;
13 import java.io.Serializable JavaDoc;
14
15 /**
16  * A class which provides an empty, transparent border which
17  * takes up space but does no drawing.
18  * <p>
19  * <strong>Warning:</strong>
20  * Serialized objects of this class will not be compatible with
21  * future Swing releases. The current serialization support is
22  * appropriate for short term storage or RMI between applications running
23  * the same version of Swing. As of 1.4, support for long term storage
24  * of all JavaBeans<sup><font size="-2">TM</font></sup>
25  * has been added to the <code>java.beans</code> package.
26  * Please see {@link java.beans.XMLEncoder}.
27  *
28  * @version 1.26 12/19/03
29  * @author David Kloba
30  */

31 public class EmptyBorder extends AbstractBorder JavaDoc implements Serializable JavaDoc
32 {
33     protected int left, right, top, bottom;
34
35     /**
36      * Creates an empty border with the specified insets.
37      * @param top the top inset of the border
38      * @param left the left inset of the border
39      * @param bottom the bottom inset of the border
40      * @param right the right inset of the border
41      */

42     public EmptyBorder(int top, int left, int bottom, int right) {
43         this.top = top;
44         this.right = right;
45         this.bottom = bottom;
46         this.left = left;
47     }
48
49     /**
50      * Creates an empty border with the specified insets.
51      * @param borderInsets the insets of the border
52      */

53     public EmptyBorder(Insets JavaDoc borderInsets) {
54         this.top = borderInsets.top;
55         this.right = borderInsets.right;
56         this.bottom = borderInsets.bottom;
57         this.left = borderInsets.left;
58     }
59
60     /**
61      * Does no drawing by default.
62      */

63     public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y, int width, int height) {
64     }
65
66     /**
67      * Returns the insets of the border.
68      * @param c the component for which this border insets value applies
69      */

70     public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
71         return getBorderInsets();
72     }
73
74     /**
75      * Reinitialize the insets parameter with this Border's current Insets.
76      * @param c the component for which this border insets value applies
77      * @param insets the object to be reinitialized
78      */

79     public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc insets) {
80         insets.left = left;
81         insets.top = top;
82         insets.right = right;
83         insets.bottom = bottom;
84         return insets;
85     }
86
87     /**
88      * Returns the insets of the border.
89      */

90     public Insets JavaDoc getBorderInsets() {
91         return new Insets JavaDoc(top, left, bottom, right);
92     }
93
94     /**
95      * Returns whether or not the border is opaque.
96      * Returns false by default.
97      */

98     public boolean isBorderOpaque() { return false; }
99
100 }
101
Popular Tags