Home » openjdk-7 » javax » swing » border » [javadoc | source]

    1   /*
    2    * Copyright (c) 1997, 2007, 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.border;
   26   
   27   import java.awt.Graphics;
   28   import java.awt.Insets;
   29   import java.awt.Rectangle;
   30   import java.awt.Component;
   31   import java.io.Serializable;
   32   import java.beans.ConstructorProperties;
   33   
   34   /**
   35    * A class which provides an empty, transparent border which
   36    * takes up space but does no drawing.
   37    * <p>
   38    * <strong>Warning:</strong>
   39    * Serialized objects of this class will not be compatible with
   40    * future Swing releases. The current serialization support is
   41    * appropriate for short term storage or RMI between applications running
   42    * the same version of Swing.  As of 1.4, support for long term storage
   43    * of all JavaBeans<sup><font size="-2">TM</font></sup>
   44    * has been added to the <code>java.beans</code> package.
   45    * Please see {@link java.beans.XMLEncoder}.
   46    *
   47    * @author David Kloba
   48    */
   49   public class EmptyBorder extends AbstractBorder implements Serializable
   50   {
   51       protected int left, right, top, bottom;
   52   
   53       /**
   54        * Creates an empty border with the specified insets.
   55        * @param top the top inset of the border
   56        * @param left the left inset of the border
   57        * @param bottom the bottom inset of the border
   58        * @param right the right inset of the border
   59        */
   60       public EmptyBorder(int top, int left, int bottom, int right)   {
   61           this.top = top;
   62           this.right = right;
   63           this.bottom = bottom;
   64           this.left = left;
   65       }
   66   
   67       /**
   68        * Creates an empty border with the specified insets.
   69        * @param borderInsets the insets of the border
   70        */
   71       @ConstructorProperties({"borderInsets"})
   72       public EmptyBorder(Insets borderInsets)   {
   73           this.top = borderInsets.top;
   74           this.right = borderInsets.right;
   75           this.bottom = borderInsets.bottom;
   76           this.left = borderInsets.left;
   77       }
   78   
   79       /**
   80        * Does no drawing by default.
   81        */
   82       public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   83       }
   84   
   85       /**
   86        * Reinitialize the insets parameter with this Border's current Insets.
   87        * @param c the component for which this border insets value applies
   88        * @param insets the object to be reinitialized
   89        */
   90       public Insets getBorderInsets(Component c, Insets insets) {
   91           insets.left = left;
   92           insets.top = top;
   93           insets.right = right;
   94           insets.bottom = bottom;
   95           return insets;
   96       }
   97   
   98       /**
   99        * Returns the insets of the border.
  100        * @since 1.3
  101        */
  102       public Insets getBorderInsets() {
  103           return new Insets(top, left, bottom, right);
  104       }
  105   
  106       /**
  107        * Returns whether or not the border is opaque.
  108        * Returns false by default.
  109        */
  110       public boolean isBorderOpaque() { return false; }
  111   
  112   }

Home » openjdk-7 » javax » swing » border » [javadoc | source]