001 /*
002 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.swing.border;
026
027 import java.awt.Graphics;
028 import java.awt.Insets;
029 import java.awt.Rectangle;
030 import java.awt.Component;
031 import java.io.Serializable;
032 import java.beans.ConstructorProperties;
033
034 /**
035 * A class which provides an empty, transparent border which
036 * takes up space but does no drawing.
037 * <p>
038 * <strong>Warning:</strong>
039 * Serialized objects of this class will not be compatible with
040 * future Swing releases. The current serialization support is
041 * appropriate for short term storage or RMI between applications running
042 * the same version of Swing. As of 1.4, support for long term storage
043 * of all JavaBeans<sup><font size="-2">TM</font></sup>
044 * has been added to the <code>java.beans</code> package.
045 * Please see {@link java.beans.XMLEncoder}.
046 *
047 * @version 1.33 05/05/07
048 * @author David Kloba
049 */
050 public class EmptyBorder extends AbstractBorder implements Serializable {
051 protected int left, right, top, bottom;
052
053 /**
054 * Creates an empty border with the specified insets.
055 * @param top the top inset of the border
056 * @param left the left inset of the border
057 * @param bottom the bottom inset of the border
058 * @param right the right inset of the border
059 */
060 public EmptyBorder(int top, int left, int bottom, int right) {
061 this .top = top;
062 this .right = right;
063 this .bottom = bottom;
064 this .left = left;
065 }
066
067 /**
068 * Creates an empty border with the specified insets.
069 * @param borderInsets the insets of the border
070 */
071 @ConstructorProperties({"borderInsets"})
072 public EmptyBorder(Insets borderInsets) {
073 this .top = borderInsets.top;
074 this .right = borderInsets.right;
075 this .bottom = borderInsets.bottom;
076 this .left = borderInsets.left;
077 }
078
079 /**
080 * Does no drawing by default.
081 */
082 public void paintBorder(Component c, Graphics g, int x, int y,
083 int width, int height) {
084 }
085
086 /**
087 * Returns the insets of the border.
088 * @param c the component for which this border insets value applies
089 * @since 1.3
090 */
091 public Insets getBorderInsets(Component c) {
092 return getBorderInsets();
093 }
094
095 /**
096 * Reinitialize the insets parameter with this Border's current Insets.
097 * @param c the component for which this border insets value applies
098 * @param insets the object to be reinitialized
099 */
100 public Insets getBorderInsets(Component c, Insets insets) {
101 insets.left = left;
102 insets.top = top;
103 insets.right = right;
104 insets.bottom = bottom;
105 return insets;
106 }
107
108 /**
109 * Returns the insets of the border.
110 * @since 1.3
111 */
112 public Insets getBorderInsets() {
113 return new Insets(top, left, bottom, right);
114 }
115
116 /**
117 * Returns whether or not the border is opaque.
118 * Returns false by default.
119 */
120 public boolean isBorderOpaque() {
121 return false;
122 }
123
124 }
|