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

    1   /*
    2    * Copyright (c) 1997, 2010, 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.Color;
   28   import java.awt.Component;
   29   import java.awt.Dimension;
   30   import java.awt.Font;
   31   import java.awt.Graphics;
   32   import java.awt.Graphics2D;
   33   import java.awt.Insets;
   34   import java.awt.Rectangle;
   35   import java.awt.geom.Path2D;
   36   import java.beans.ConstructorProperties;
   37   import javax.swing.JComponent;
   38   import javax.swing.JLabel;
   39   import javax.swing.UIManager;
   40   import javax.swing.plaf.basic.BasicHTML;
   41   
   42   /**
   43    * A class which implements an arbitrary border
   44    * with the addition of a String title in a
   45    * specified position and justification.
   46    * <p>
   47    * If the border, font, or color property values are not
   48    * specified in the constuctor or by invoking the appropriate
   49    * set methods, the property values will be defined by the current
   50    * look and feel, using the following property names in the
   51    * Defaults Table:
   52    * <ul>
   53    * <li>&quot;TitledBorder.border&quot;
   54    * <li>&quot;TitledBorder.font&quot;
   55    * <li>&quot;TitledBorder.titleColor&quot;
   56    * </ul>
   57    * <p>
   58    * <strong>Warning:</strong>
   59    * Serialized objects of this class will not be compatible with
   60    * future Swing releases. The current serialization support is
   61    * appropriate for short term storage or RMI between applications running
   62    * the same version of Swing.  As of 1.4, support for long term storage
   63    * of all JavaBeans<sup><font size="-2">TM</font></sup>
   64    * has been added to the <code>java.beans</code> package.
   65    * Please see {@link java.beans.XMLEncoder}.
   66    *
   67    * @author David Kloba
   68    * @author Amy Fowler
   69    */
   70   public class TitledBorder extends AbstractBorder
   71   {
   72       protected String title;
   73       protected Border border;
   74       protected int titlePosition;
   75       protected int titleJustification;
   76       protected Font titleFont;
   77       protected Color titleColor;
   78   
   79       private final JLabel label;
   80   
   81       /**
   82        * Use the default vertical orientation for the title text.
   83        */
   84       static public final int     DEFAULT_POSITION        = 0;
   85       /** Position the title above the border's top line. */
   86       static public final int     ABOVE_TOP               = 1;
   87       /** Position the title in the middle of the border's top line. */
   88       static public final int     TOP                     = 2;
   89       /** Position the title below the border's top line. */
   90       static public final int     BELOW_TOP               = 3;
   91       /** Position the title above the border's bottom line. */
   92       static public final int     ABOVE_BOTTOM            = 4;
   93       /** Position the title in the middle of the border's bottom line. */
   94       static public final int     BOTTOM                  = 5;
   95       /** Position the title below the border's bottom line. */
   96       static public final int     BELOW_BOTTOM            = 6;
   97   
   98       /**
   99        * Use the default justification for the title text.
  100        */
  101       static public final int     DEFAULT_JUSTIFICATION   = 0;
  102       /** Position title text at the left side of the border line. */
  103       static public final int     LEFT                    = 1;
  104       /** Position title text in the center of the border line. */
  105       static public final int     CENTER                  = 2;
  106       /** Position title text at the right side of the border line. */
  107       static public final int     RIGHT                   = 3;
  108       /** Position title text at the left side of the border line
  109        *  for left to right orientation, at the right side of the
  110        *  border line for right to left orientation.
  111        */
  112       static public final int     LEADING = 4;
  113       /** Position title text at the right side of the border line
  114        *  for left to right orientation, at the left side of the
  115        *  border line for right to left orientation.
  116        */
  117       static public final int     TRAILING = 5;
  118   
  119       // Space between the border and the component's edge
  120       static protected final int EDGE_SPACING = 2;
  121   
  122       // Space between the border and text
  123       static protected final int TEXT_SPACING = 2;
  124   
  125       // Horizontal inset of text that is left or right justified
  126       static protected final int TEXT_INSET_H = 5;
  127   
  128       /**
  129        * Creates a TitledBorder instance.
  130        *
  131        * @param title  the title the border should display
  132        */
  133       public TitledBorder(String title) {
  134           this(null, title, LEADING, DEFAULT_POSITION, null, null);
  135       }
  136   
  137       /**
  138        * Creates a TitledBorder instance with the specified border
  139        * and an empty title.
  140        *
  141        * @param border  the border
  142        */
  143       public TitledBorder(Border border) {
  144           this(border, "", LEADING, DEFAULT_POSITION, null, null);
  145       }
  146   
  147       /**
  148        * Creates a TitledBorder instance with the specified border
  149        * and title.
  150        *
  151        * @param border  the border
  152        * @param title  the title the border should display
  153        */
  154       public TitledBorder(Border border, String title) {
  155           this(border, title, LEADING, DEFAULT_POSITION, null, null);
  156       }
  157   
  158       /**
  159        * Creates a TitledBorder instance with the specified border,
  160        * title, title-justification, and title-position.
  161        *
  162        * @param border  the border
  163        * @param title  the title the border should display
  164        * @param titleJustification the justification for the title
  165        * @param titlePosition the position for the title
  166        */
  167       public TitledBorder(Border border,
  168                           String title,
  169                           int titleJustification,
  170                           int titlePosition) {
  171           this(border, title, titleJustification,
  172                titlePosition, null, null);
  173       }
  174   
  175       /**
  176        * Creates a TitledBorder instance with the specified border,
  177        * title, title-justification, title-position, and title-font.
  178        *
  179        * @param border  the border
  180        * @param title  the title the border should display
  181        * @param titleJustification the justification for the title
  182        * @param titlePosition the position for the title
  183        * @param titleFont the font for rendering the title
  184        */
  185       public TitledBorder(Border border,
  186                           String title,
  187                           int titleJustification,
  188                           int titlePosition,
  189                           Font titleFont) {
  190           this(border, title, titleJustification,
  191                titlePosition, titleFont, null);
  192       }
  193   
  194       /**
  195        * Creates a TitledBorder instance with the specified border,
  196        * title, title-justification, title-position, title-font, and
  197        * title-color.
  198        *
  199        * @param border  the border
  200        * @param title  the title the border should display
  201        * @param titleJustification the justification for the title
  202        * @param titlePosition the position for the title
  203        * @param titleFont the font of the title
  204        * @param titleColor the color of the title
  205        */
  206       @ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
  207       public TitledBorder(Border border,
  208                           String title,
  209                           int titleJustification,
  210                           int titlePosition,
  211                           Font titleFont,
  212                           Color titleColor) {
  213           this.title = title;
  214           this.border = border;
  215           this.titleFont = titleFont;
  216           this.titleColor = titleColor;
  217   
  218           setTitleJustification(titleJustification);
  219           setTitlePosition(titlePosition);
  220   
  221           this.label = new JLabel();
  222           this.label.setOpaque(false);
  223           this.label.putClientProperty(BasicHTML.propertyKey, null);
  224       }
  225   
  226       /**
  227        * Paints the border for the specified component with the
  228        * specified position and size.
  229        * @param c the component for which this border is being painted
  230        * @param g the paint graphics
  231        * @param x the x position of the painted border
  232        * @param y the y position of the painted border
  233        * @param width the width of the painted border
  234        * @param height the height of the painted border
  235        */
  236       public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  237           Border border = getBorder();
  238           String title = getTitle();
  239           if ((title != null) && !title.isEmpty()) {
  240               int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
  241               JLabel label = getLabel(c);
  242               Dimension size = label.getPreferredSize();
  243               Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0));
  244   
  245               int borderX = x + edge;
  246               int borderY = y + edge;
  247               int borderW = width - edge - edge;
  248               int borderH = height - edge - edge;
  249   
  250               int labelY = y;
  251               int labelH = size.height;
  252               int position = getPosition();
  253               switch (position) {
  254                   case ABOVE_TOP:
  255                       insets.left = 0;
  256                       insets.right = 0;
  257                       borderY += labelH - edge;
  258                       borderH -= labelH - edge;
  259                       break;
  260                   case TOP:
  261                       insets.top = edge + insets.top/2 - labelH/2;
  262                       if (insets.top < edge) {
  263                           borderY -= insets.top;
  264                           borderH += insets.top;
  265                       }
  266                       else {
  267                           labelY += insets.top;
  268                       }
  269                       break;
  270                   case BELOW_TOP:
  271                       labelY += insets.top + edge;
  272                       break;
  273                   case ABOVE_BOTTOM:
  274                       labelY += height - labelH - insets.bottom - edge;
  275                       break;
  276                   case BOTTOM:
  277                       labelY += height - labelH;
  278                       insets.bottom = edge + (insets.bottom - labelH) / 2;
  279                       if (insets.bottom < edge) {
  280                           borderH += insets.bottom;
  281                       }
  282                       else {
  283                           labelY -= insets.bottom;
  284                       }
  285                       break;
  286                   case BELOW_BOTTOM:
  287                       insets.left = 0;
  288                       insets.right = 0;
  289                       labelY += height - labelH;
  290                       borderH -= labelH - edge;
  291                       break;
  292               }
  293               insets.left += edge + TEXT_INSET_H;
  294               insets.right += edge + TEXT_INSET_H;
  295   
  296               int labelX = x;
  297               int labelW = width - insets.left - insets.right;
  298               if (labelW > size.width) {
  299                   labelW = size.width;
  300               }
  301               switch (getJustification(c)) {
  302                   case LEFT:
  303                       labelX += insets.left;
  304                       break;
  305                   case RIGHT:
  306                       labelX += width - insets.right - labelW;
  307                       break;
  308                   case CENTER:
  309                       labelX += (width - labelW) / 2;
  310                       break;
  311               }
  312   
  313               if (border != null) {
  314                   if ((position != TOP) && (position != BOTTOM)) {
  315                       border.paintBorder(c, g, borderX, borderY, borderW, borderH);
  316                   }
  317                   else {
  318                       Graphics g2 = g.create();
  319                       if (g2 instanceof Graphics2D) {
  320                           Graphics2D g2d = (Graphics2D) g2;
  321                           Path2D path = new Path2D.Float();
  322                           path.append(new Rectangle(borderX, borderY, borderW, labelY - borderY), false);
  323                           path.append(new Rectangle(borderX, labelY, labelX - borderX - TEXT_SPACING, labelH), false);
  324                           path.append(new Rectangle(labelX + labelW + TEXT_SPACING, labelY, borderX - labelX + borderW - labelW - TEXT_SPACING, labelH), false);
  325                           path.append(new Rectangle(borderX, labelY + labelH, borderW, borderY - labelY + borderH - labelH), false);
  326                           g2d.clip(path);
  327                       }
  328                       border.paintBorder(c, g2, borderX, borderY, borderW, borderH);
  329                       g2.dispose();
  330                   }
  331               }
  332               g.translate(labelX, labelY);
  333               label.setSize(labelW, labelH);
  334               label.paint(g);
  335               g.translate(-labelX, -labelY);
  336           }
  337           else if (border != null) {
  338               border.paintBorder(c, g, x, y, width, height);
  339           }
  340       }
  341   
  342       /**
  343        * Reinitialize the insets parameter with this Border's current Insets.
  344        * @param c the component for which this border insets value applies
  345        * @param insets the object to be reinitialized
  346        */
  347       public Insets getBorderInsets(Component c, Insets insets) {
  348           Border border = getBorder();
  349           insets = getBorderInsets(border, c, insets);
  350   
  351           String title = getTitle();
  352           if ((title != null) && !title.isEmpty()) {
  353               int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
  354               JLabel label = getLabel(c);
  355               Dimension size = label.getPreferredSize();
  356   
  357               switch (getPosition()) {
  358                   case ABOVE_TOP:
  359                       insets.top += size.height - edge;
  360                       break;
  361                   case TOP: {
  362                       if (insets.top < size.height) {
  363                           insets.top = size.height - edge;
  364                       }
  365                       break;
  366                   }
  367                   case BELOW_TOP:
  368                       insets.top += size.height;
  369                       break;
  370                   case ABOVE_BOTTOM:
  371                       insets.bottom += size.height;
  372                       break;
  373                   case BOTTOM: {
  374                       if (insets.bottom < size.height) {
  375                           insets.bottom = size.height - edge;
  376                       }
  377                       break;
  378                   }
  379                   case BELOW_BOTTOM:
  380                       insets.bottom += size.height - edge;
  381                       break;
  382               }
  383               insets.top += edge + TEXT_SPACING;
  384               insets.left += edge + TEXT_SPACING;
  385               insets.right += edge + TEXT_SPACING;
  386               insets.bottom += edge + TEXT_SPACING;
  387           }
  388           return insets;
  389       }
  390   
  391       /**
  392        * Returns whether or not the border is opaque.
  393        */
  394       public boolean isBorderOpaque() {
  395           return false;
  396       }
  397   
  398       /**
  399        * Returns the title of the titled border.
  400        *
  401        * @return the title of the titled border
  402        */
  403       public String getTitle() {
  404           return title;
  405       }
  406   
  407       /**
  408        * Returns the border of the titled border.
  409        *
  410        * @return the border of the titled border
  411        */
  412       public Border getBorder() {
  413           return border != null
  414                   ? border
  415                   : UIManager.getBorder("TitledBorder.border");
  416       }
  417   
  418       /**
  419        * Returns the title-position of the titled border.
  420        *
  421        * @return the title-position of the titled border
  422        */
  423       public int getTitlePosition() {
  424           return titlePosition;
  425       }
  426   
  427       /**
  428        * Returns the title-justification of the titled border.
  429        *
  430        * @return the title-justification of the titled border
  431        */
  432       public int getTitleJustification() {
  433           return titleJustification;
  434       }
  435   
  436       /**
  437        * Returns the title-font of the titled border.
  438        *
  439        * @return the title-font of the titled border
  440        */
  441       public Font getTitleFont() {
  442           return titleFont;
  443       }
  444   
  445       /**
  446        * Returns the title-color of the titled border.
  447        *
  448        * @return the title-color of the titled border
  449        */
  450       public Color getTitleColor() {
  451           return titleColor;
  452       }
  453   
  454   
  455       // REMIND(aim): remove all or some of these set methods?
  456   
  457       /**
  458        * Sets the title of the titled border.
  459        * @param title  the title for the border
  460        */
  461       public void setTitle(String title) {
  462           this.title = title;
  463       }
  464   
  465       /**
  466        * Sets the border of the titled border.
  467        * @param border the border
  468        */
  469       public void setBorder(Border border) {
  470           this.border = border;
  471       }
  472   
  473       /**
  474        * Sets the title-position of the titled border.
  475        * @param titlePosition the position for the border
  476        */
  477       public void setTitlePosition(int titlePosition) {
  478           switch (titlePosition) {
  479               case ABOVE_TOP:
  480               case TOP:
  481               case BELOW_TOP:
  482               case ABOVE_BOTTOM:
  483               case BOTTOM:
  484               case BELOW_BOTTOM:
  485               case DEFAULT_POSITION:
  486                   this.titlePosition = titlePosition;
  487                   break;
  488               default:
  489                   throw new IllegalArgumentException(titlePosition +
  490                           " is not a valid title position.");
  491           }
  492       }
  493   
  494       /**
  495        * Sets the title-justification of the titled border.
  496        * @param titleJustification the justification for the border
  497        */
  498       public void setTitleJustification(int titleJustification) {
  499           switch (titleJustification) {
  500               case DEFAULT_JUSTIFICATION:
  501               case LEFT:
  502               case CENTER:
  503               case RIGHT:
  504               case LEADING:
  505               case TRAILING:
  506                   this.titleJustification = titleJustification;
  507                   break;
  508               default:
  509                   throw new IllegalArgumentException(titleJustification +
  510                           " is not a valid title justification.");
  511           }
  512       }
  513   
  514       /**
  515        * Sets the title-font of the titled border.
  516        * @param titleFont the font for the border title
  517        */
  518       public void setTitleFont(Font titleFont) {
  519           this.titleFont = titleFont;
  520       }
  521   
  522       /**
  523        * Sets the title-color of the titled border.
  524        * @param titleColor the color for the border title
  525        */
  526       public void setTitleColor(Color titleColor) {
  527           this.titleColor = titleColor;
  528       }
  529   
  530       /**
  531        * Returns the minimum dimensions this border requires
  532        * in order to fully display the border and title.
  533        * @param c the component where this border will be drawn
  534        * @return the {@code Dimension} object
  535        */
  536       public Dimension getMinimumSize(Component c) {
  537           Insets insets = getBorderInsets(c);
  538           Dimension minSize = new Dimension(insets.right+insets.left,
  539                                             insets.top+insets.bottom);
  540           String title = getTitle();
  541           if ((title != null) && !title.isEmpty()) {
  542               JLabel label = getLabel(c);
  543               Dimension size = label.getPreferredSize();
  544   
  545               int position = getPosition();
  546               if ((position != ABOVE_TOP) && (position != BELOW_BOTTOM)) {
  547                   minSize.width += size.width;
  548               }
  549               else if (minSize.width < size.width) {
  550                   minSize.width += size.width;
  551               }
  552           }
  553           return minSize;
  554       }
  555   
  556       /**
  557        * Returns the baseline.
  558        *
  559        * @throws NullPointerException {@inheritDoc}
  560        * @throws IllegalArgumentException {@inheritDoc}
  561        * @see javax.swing.JComponent#getBaseline(int, int)
  562        * @since 1.6
  563        */
  564       public int getBaseline(Component c, int width, int height) {
  565           if (c == null) {
  566               throw new NullPointerException("Must supply non-null component");
  567           }
  568           if (width < 0) {
  569               throw new IllegalArgumentException("Width must be >= 0");
  570           }
  571           if (height < 0) {
  572               throw new IllegalArgumentException("Height must be >= 0");
  573           }
  574           Border border = getBorder();
  575           String title = getTitle();
  576           if ((title != null) && !title.isEmpty()) {
  577               int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
  578               JLabel label = getLabel(c);
  579               Dimension size = label.getPreferredSize();
  580               Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0));
  581   
  582               int baseline = label.getBaseline(size.width, size.height);
  583               switch (getPosition()) {
  584                   case ABOVE_TOP:
  585                       return baseline;
  586                   case TOP:
  587                       insets.top = edge + (insets.top - size.height) / 2;
  588                       return (insets.top < edge)
  589                               ? baseline
  590                               : baseline + insets.top;
  591                   case BELOW_TOP:
  592                       return baseline + insets.top + edge;
  593                   case ABOVE_BOTTOM:
  594                       return baseline + height - size.height - insets.bottom - edge;
  595                   case BOTTOM:
  596                       insets.bottom = edge + (insets.bottom - size.height) / 2;
  597                       return (insets.bottom < edge)
  598                               ? baseline + height - size.height
  599                               : baseline + height - size.height + insets.bottom;
  600                   case BELOW_BOTTOM:
  601                       return baseline + height - size.height;
  602               }
  603           }
  604           return -1;
  605       }
  606   
  607       /**
  608        * Returns an enum indicating how the baseline of the border
  609        * changes as the size changes.
  610        *
  611        * @throws NullPointerException {@inheritDoc}
  612        * @see javax.swing.JComponent#getBaseline(int, int)
  613        * @since 1.6
  614        */
  615       public Component.BaselineResizeBehavior getBaselineResizeBehavior(
  616               Component c) {
  617           super.getBaselineResizeBehavior(c);
  618           switch (getPosition()) {
  619               case TitledBorder.ABOVE_TOP:
  620               case TitledBorder.TOP:
  621               case TitledBorder.BELOW_TOP:
  622                   return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
  623               case TitledBorder.ABOVE_BOTTOM:
  624               case TitledBorder.BOTTOM:
  625               case TitledBorder.BELOW_BOTTOM:
  626                   return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
  627           }
  628           return Component.BaselineResizeBehavior.OTHER;
  629       }
  630   
  631       private int getPosition() {
  632           int position = getTitlePosition();
  633           if (position != DEFAULT_POSITION) {
  634               return position;
  635           }
  636           Object value = UIManager.get("TitledBorder.position");
  637           if (value instanceof Integer) {
  638               int i = (Integer) value;
  639               if ((0 < i) && (i <= 6)) {
  640                   return i;
  641               }
  642           }
  643           else if (value instanceof String) {
  644               String s = (String) value;
  645               if (s.equalsIgnoreCase("ABOVE_TOP")) {
  646                   return ABOVE_TOP;
  647               }
  648               if (s.equalsIgnoreCase("TOP")) {
  649                   return TOP;
  650               }
  651               if (s.equalsIgnoreCase("BELOW_TOP")) {
  652                   return BELOW_TOP;
  653               }
  654               if (s.equalsIgnoreCase("ABOVE_BOTTOM")) {
  655                   return ABOVE_BOTTOM;
  656               }
  657               if (s.equalsIgnoreCase("BOTTOM")) {
  658                   return BOTTOM;
  659               }
  660               if (s.equalsIgnoreCase("BELOW_BOTTOM")) {
  661                   return BELOW_BOTTOM;
  662               }
  663           }
  664           return TOP;
  665       }
  666   
  667       private int getJustification(Component c) {
  668           int justification = getTitleJustification();
  669           if ((justification == LEADING) || (justification == DEFAULT_JUSTIFICATION)) {
  670               return c.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT;
  671           }
  672           if (justification == TRAILING) {
  673               return c.getComponentOrientation().isLeftToRight() ? RIGHT : LEFT;
  674           }
  675           return justification;
  676       }
  677   
  678       protected Font getFont(Component c) {
  679           Font font = getTitleFont();
  680           if (font != null) {
  681               return font;
  682           }
  683           font = UIManager.getFont("TitledBorder.font");
  684           if (font != null) {
  685               return font;
  686           }
  687           if (c != null) {
  688               font = c.getFont();
  689               if (font != null) {
  690                   return font;
  691               }
  692           }
  693           return new Font(Font.DIALOG, Font.PLAIN, 12);
  694       }
  695   
  696       private Color getColor(Component c) {
  697           Color color = getTitleColor();
  698           if (color != null) {
  699               return color;
  700           }
  701           color = UIManager.getColor("TitledBorder.titleColor");
  702           if (color != null) {
  703               return color;
  704           }
  705           return (c != null)
  706                   ? c.getForeground()
  707                   : null;
  708       }
  709   
  710       private JLabel getLabel(Component c) {
  711           this.label.setText(getTitle());
  712           this.label.setFont(getFont(c));
  713           this.label.setForeground(getColor(c));
  714           this.label.setComponentOrientation(c.getComponentOrientation());
  715           this.label.setEnabled(c.isEnabled());
  716           return this.label;
  717       }
  718   
  719       private static Insets getBorderInsets(Border border, Component c, Insets insets) {
  720           if (border == null) {
  721               insets.set(0, 0, 0, 0);
  722           }
  723           else if (border instanceof AbstractBorder) {
  724               AbstractBorder ab = (AbstractBorder) border;
  725               insets = ab.getBorderInsets(c, insets);
  726           }
  727           else {
  728               Insets i = border.getBorderInsets(c);
  729               insets.set(i.top, i.left, i.bottom, i.right);
  730           }
  731           return insets;
  732       }
  733   }

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