Source for javax.swing.plaf.BorderUIResource

   1: /* BorderUIResource.java
   2:    Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10:  
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.swing.plaf;
  40: 
  41: import java.awt.Color;
  42: import java.awt.Component;
  43: import java.awt.Font;
  44: import java.awt.Graphics;
  45: import java.awt.Insets;
  46: import java.io.Serializable;
  47: 
  48: import javax.swing.Icon;
  49: import javax.swing.border.BevelBorder;
  50: import javax.swing.border.Border;
  51: import javax.swing.border.CompoundBorder;
  52: import javax.swing.border.EmptyBorder;
  53: import javax.swing.border.EtchedBorder;
  54: import javax.swing.border.LineBorder;
  55: import javax.swing.border.MatteBorder;
  56: import javax.swing.border.TitledBorder;
  57: 
  58: /**
  59:  * A wrapper for {@link javax.swing.border.Border} that also
  60:  * implements the {@link UIResource} marker interface.  This is useful
  61:  * for implementing pluggable look-and-feels: When switching the
  62:  * current LookAndFeel, only those borders are replaced that are
  63:  * marked as {@link UIResource}.  For this reason, a look-and-feel
  64:  * should always install borders that implement
  65:  * <code>UIResource</code>, such as the borders provided by this
  66:  * class.
  67:  *
  68:  * @serial
  69:  * @serialField delegate Border the <code>Border</code> wrapped
  70:  *
  71:  * @author Brian Jones (cbj@gnu.org)
  72:  * @author Sascha Brawer (brawer@dandelis.ch)
  73:  */
  74: public class BorderUIResource implements Border, UIResource, Serializable
  75: {
  76:   /**
  77:    * Verified using the <code>serialver</code> tool
  78:    * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
  79:    */
  80:   static final long serialVersionUID = -3440553684010079691L;
  81: 
  82: 
  83:   /**
  84:    * A shared instance of an {@link EtchedBorderUIResource}, or
  85:    * <code>null</code> if the {@link #getEtchedBorderUIResource()}
  86:    * method has not yet been called.
  87:    */
  88:   private static Border etchedBorderUIResource;
  89: 
  90: 
  91:   /**
  92:    * A shared instance of a {@link BevelBorderUIResource} whose
  93:    * <code>bevelType</code> is {@link
  94:    * javax.swing.border.BevelBorder#LOWERED}, or <code>null</code> if
  95:    * the {@link #getLoweredBevelBorderUIResource()} has not yet been
  96:    * called.
  97:    */
  98:   private static Border loweredBevelBorderUIResource;
  99:   
 100:   
 101:   /**
 102:    * A shared instance of a {@link BevelBorderUIResource} whose
 103:    * <code>bevelType</code> is {@link
 104:    * javax.swing.border.BevelBorder#RAISED}, or <code>null</code> if
 105:    * the {@link #getRaisedBevelBorderUIResource()} has not yet been
 106:    * called.
 107:    */
 108:   private static Border raisedBevelBorderUIResource;
 109:   
 110:   
 111:   /**
 112:    * A shared instance of a {@link LineBorderUIResource} for
 113:    * a one-pixel thick black line, or <code>null</code> if
 114:    * the {@link #getBlackLineBorderUIResource()} has not yet been
 115:    * called.
 116:    */
 117:   private static Border blackLineBorderUIResource;
 118: 
 119: 
 120:   /**
 121:    * Returns a shared instance of an etched border which also
 122:    * is marked as an {@link UIResource}.
 123:    *
 124:    * @see javax.swing.border.EtchedBorder
 125:    */
 126:   public static Border getEtchedBorderUIResource()
 127:   {
 128:     /* Swing is not designed to be thread-safe, so there is no
 129:      * need to synchronize the access to the global variable.
 130:      */
 131:     if (etchedBorderUIResource == null)
 132:       etchedBorderUIResource = new EtchedBorderUIResource();
 133:     return etchedBorderUIResource;
 134:   }
 135:   
 136: 
 137:   /**
 138:    * Returns a shared instance of {@link BevelBorderUIResource} whose
 139:    * <code>bevelType</code> is {@link
 140:    * javax.swing.border.BevelBorder#LOWERED}.
 141:    *
 142:    * @see javax.swing.border.BevelBorder
 143:    */
 144:   public static Border getLoweredBevelBorderUIResource()
 145:   {
 146:     /* Swing is not designed to be thread-safe, so there is no
 147:      * need to synchronize the access to the global variable.
 148:      */
 149:     if (loweredBevelBorderUIResource == null)
 150:       loweredBevelBorderUIResource = new BevelBorderUIResource(
 151:         BevelBorder.LOWERED);
 152:     return loweredBevelBorderUIResource;
 153:   }
 154: 
 155: 
 156:   /**
 157:    * Returns a shared instance of {@link BevelBorderUIResource} whose
 158:    * <code>bevelType</code> is {@link
 159:    * javax.swing.border.BevelBorder#RAISED}.
 160:    *
 161:    * @see javax.swing.border.BevelBorder
 162:    */
 163:   public static Border getRaisedBevelBorderUIResource()
 164:   {
 165:     /* Swing is not designed to be thread-safe, so there is no
 166:      * need to synchronize the access to the global variable.
 167:      */
 168:     if (raisedBevelBorderUIResource == null)
 169:       raisedBevelBorderUIResource = new BevelBorderUIResource(
 170:         BevelBorder.RAISED);
 171:     return raisedBevelBorderUIResource;
 172:   }
 173:   
 174:   
 175:   /**
 176:    * Returns a shared instance of {@link LineBorderUIResource} for
 177:    * a black, one-pixel width border.
 178:    *
 179:    * @see javax.swing.border.LineBorder
 180:    */
 181:   public static Border getBlackLineBorderUIResource()
 182:   {
 183:     /* Swing is not designed to be thread-safe, so there is no
 184:      * need to synchronize the access to the global variable.
 185:      */
 186:     if (blackLineBorderUIResource == null)
 187:       blackLineBorderUIResource = new LineBorderUIResource(Color.black);
 188:     return blackLineBorderUIResource;
 189:   }
 190: 
 191: 
 192:   /**
 193:    * The wrapped border.
 194:    */
 195:   private Border delegate;
 196:   
 197:   
 198:   /**
 199:    * Constructs a <code>BorderUIResource</code> for wrapping
 200:    * a <code>Border</code> object.
 201:    * 
 202:    * @param delegate the border to be wrapped.
 203:    */
 204:   public BorderUIResource(Border delegate)
 205:   {
 206:     if (delegate == null)
 207:       throw new IllegalArgumentException();
 208:     
 209:     this.delegate = delegate;
 210:   }
 211: 
 212:   
 213:   /**
 214:    * Paints the border around an enclosed component by calling
 215:    * the <code>paintBorder</code> method of the wrapped delegate.
 216:    *
 217:    * @param c the component whose border is to be painted.
 218:    * @param g the graphics for painting.
 219:    * @param x the horizontal position for painting the border.
 220:    * @param y the vertical position for painting the border.
 221:    * @param width the width of the available area for painting the border.
 222:    * @param height the height of the available area for painting the border.
 223:    */
 224:   public void paintBorder(Component c, Graphics g,
 225:                           int x, int y, int width, int height)
 226:   {
 227:     delegate.paintBorder(c, g, x, y, width, height);
 228:   }
 229:   
 230:   
 231:   /**
 232:    * Measures the width of this border by calling the
 233:    * <code>getBorderInsets</code> method of the wrapped
 234:    * delegate.
 235:    *
 236:    * @param c the component whose border is to be measured.
 237:    *
 238:    * @return an Insets object whose <code>left</code>, <code>right</code>,
 239:    *         <code>top</code> and <code>bottom</code> fields indicate the
 240:    *         width of the border at the respective edge.
 241:    */
 242:   public Insets getBorderInsets(Component c)
 243:   { 
 244:     return delegate.getBorderInsets(c);
 245:   }
 246:   
 247:   
 248:   /**
 249:    * Determines whether this border fills every pixel in its area
 250:    * when painting by calling the <code>isBorderOpaque</code>
 251:    * method of the wrapped delegate.
 252:    *
 253:    * @return <code>true</code> if the border is fully opaque, or
 254:    *         <code>false</code> if some pixels of the background
 255:    *         can shine through the border.
 256:    */
 257:   public boolean isBorderOpaque()
 258:   { 
 259:     return delegate.isBorderOpaque();
 260:   }
 261: 
 262: 
 263:   /**
 264:    * A {@link javax.swing.border.BevelBorder} that also implements the
 265:    * {@link UIResource} marker interface.  This is useful for
 266:    * implementing pluggable look-and-feels: When switching the current
 267:    * LookAndFeel, only those borders are replaced that are marked as
 268:    * {@link UIResource}.  For this reason, a look-and-feel should
 269:    * always install borders that implement <code>UIResource</code>,
 270:    * such as the borders provided by this class.
 271:    *
 272:    * @author Brian Jones (cbj@gnu.org)
 273:    * @author Sascha Brawer (brawer@dandelis.ch)
 274:    */
 275:   public static class BevelBorderUIResource 
 276:     extends BevelBorder
 277:     implements UIResource, Serializable
 278:   {
 279:     private static final long serialVersionUID = -1275542891108351642L;
 280:     
 281:     /**
 282:      * Constructs a BevelBorderUIResource whose colors will be derived
 283:      * from the background of the enclosed component. The background
 284:      * color is retrieved each time the border is painted, so a border
 285:      * constructed by this method will automatically reflect a change
 286:      * to the component&#x2019;s background color.
 287:      *
 288:      * <p><img src="../border/doc-files/BevelBorder-1.png"
 289:      * width="500" height="150"
 290:      * alt="[An illustration showing raised and lowered BevelBorders]" /></p>
 291:      *
 292:      * @param bevelType the desired appearance of the border. The value
 293:      *        must be either {@link javax.swing.border.BevelBorder#RAISED}
 294:      *        or {@link javax.swing.border.BevelBorder#LOWERED}.
 295:      *
 296:      * @throws IllegalArgumentException if <code>bevelType</code> has
 297:      *         an unsupported value.
 298:      */
 299:     public BevelBorderUIResource(int bevelType) 
 300:     { 
 301:       super(bevelType);
 302:     }
 303:     
 304:     
 305:     /**
 306:      * Constructs a BevelBorderUIResource given its appearance type
 307:      * and two colors for its highlight and shadow.
 308:      *
 309:      * <p><img src="../border/doc-files/BevelBorder-2.png" width="500"
 310:      * height="150" alt="[An illustration showing BevelBorders that were
 311:      * constructed with this method]" /></p>
 312:      *
 313:      * @param bevelType the desired appearance of the border. The value
 314:      *        must be either {@link javax.swing.border.BevelBorder#RAISED}
 315:      *        or {@link javax.swing.border.BevelBorder#LOWERED}.
 316:      *
 317:      * @param highlight the color that will be used for the inner side
 318:      *        of the highlighted edges (top and left if if
 319:      *        <code>bevelType</code> is {@link
 320:      *        javax.swing.border.BevelBorder#RAISED}; bottom and right
 321:      *        otherwise). The color for the outer side is a brightened
 322:      *        version of this color.
 323:      *
 324:      * @param shadow the color that will be used for the outer side of
 325:      *        the shadowed edges (bottom and right if
 326:      *        <code>bevelType</code> is {@link
 327:      *        javax.swing.border.BevelBorder#RAISED}; top and left
 328:      *        otherwise). The color for the inner side is a brightened
 329:      *        version of this color.
 330:      *
 331:      * @throws IllegalArgumentException if <code>bevelType</code> has
 332:      *         an unsupported value.
 333:      *
 334:      * @throws NullPointerException if <code>highlight</code> or
 335:      *         <code>shadow</code> is <code>null</code>.
 336:      */
 337:     public BevelBorderUIResource(int bevelType, 
 338:                                  Color highlight, 
 339:                                  Color shadow) 
 340:     {
 341:       super(bevelType, highlight, shadow);
 342:     }
 343: 
 344: 
 345:     /**
 346:      * Constructs a BevelBorderUIResource given its appearance type
 347:      * and all its colors.
 348:      *
 349:      * <p><img src="../border/doc-files/BevelBorder-3.png" width="500"
 350:      * height="150" alt="[An illustration showing BevelBorders that
 351:      * were constructed with this method]" /></p>
 352:      *
 353:      * @param bevelType the desired appearance of the border. The value
 354:      *        must be either {@link javax.swing.border.BevelBorder#RAISED}
 355:      *        or {@link javax.swing.border.BevelBorder#LOWERED}.
 356:      *
 357:      * @param highlightOuter the color that will be used for the outer
 358:      *        side of the highlighted edges (top and left if
 359:      *        <code>bevelType</code> is {@link
 360:      *        javax.swing.border.BevelBorder#RAISED}; bottom and right
 361:      *        otherwise).
 362:      *
 363:      * @param highlightInner the color that will be used for the inner
 364:      *        side of the highlighted edges.
 365:      *
 366:      * @param shadowOuter the color that will be used for the outer
 367:      *        side of the shadowed edges (bottom and right if
 368:      *        <code>bevelType</code> is {@link
 369:      *        javax.swing.border.BevelBorder#RAISED}; top and left
 370:      *        otherwise).
 371:      *
 372:      * @param shadowInner the color that will be used for the inner
 373:      *        side of the shadowed edges.
 374:      *
 375:      * @throws IllegalArgumentException if <code>bevelType</code> has
 376:      *         an unsupported value.
 377:      *
 378:      * @throws NullPointerException if one of the passed colors
 379:      *         is <code>null</code>.
 380:      */
 381:     public BevelBorderUIResource(int bevelType,
 382:                                  Color highlightOuter,
 383:                                  Color highlightInner,
 384:                                  Color shadowOuter,
 385:                                  Color shadowInner) 
 386:     {
 387:       super(bevelType,
 388:             highlightOuter, highlightInner,
 389:             shadowOuter, shadowInner);
 390:     }
 391:   }
 392:   
 393:   
 394:   /**
 395:    * A {@link javax.swing.border.CompoundBorder} that also implements the
 396:    * {@link UIResource} marker interface.  This is useful for
 397:    * implementing pluggable look-and-feels: When switching the current
 398:    * LookAndFeel, only those borders are replaced that are marked as
 399:    * {@link UIResource}.  For this reason, a look-and-feel should
 400:    * always install borders that implement <code>UIResource</code>,
 401:    * such as the borders provided by this class.
 402:    *
 403:    * @author Brian Jones (cbj@gnu.org)
 404:    * @author Sascha Brawer (brawer@dandelis.ch)
 405:    */
 406:   public static class CompoundBorderUIResource
 407:     extends CompoundBorder
 408:     implements UIResource, Serializable
 409:   {
 410:     private static final long serialVersionUID = 7550017084975167341L;
 411:     
 412:     /**
 413:      * Constructs a CompoundBorderUIResource with the specified inside
 414:      * and outside borders.
 415:      *
 416:      * @param outsideBorder the outside border, which is painted to the
 417:      *        outside of both <code>insideBorder</code> and the enclosed
 418:      *        component. It is acceptable to pass <code>null</code>, in
 419:      *        which case no outside border is painted.
 420:      *
 421:      * @param insideBorder the inside border, which is painted to
 422:      *        between <code>outsideBorder</code> and the enclosed
 423:      *        component. It is acceptable to pass <code>null</code>, in
 424:      *        which case no inside border is painted.
 425:      */
 426:     public CompoundBorderUIResource(Border outsideBorder,
 427:                                     Border insideBorder)
 428:     {
 429:       super(outsideBorder, insideBorder);
 430:     }
 431:   }
 432:   
 433:   
 434:   /**
 435:    * An {@link javax.swing.border.EmptyBorder} that also implements the
 436:    * {@link UIResource} marker interface.  This is useful for
 437:    * implementing pluggable look-and-feels: When switching the current
 438:    * LookAndFeel, only those borders are replaced that are marked as
 439:    * {@link UIResource}.  For this reason, a look-and-feel should
 440:    * always install borders that implement <code>UIResource</code>,
 441:    * such as the borders provided by this class.
 442:    *
 443:    * <p><img src="../border/doc-files/EmptyBorder-1.png"
 444:    * width="290" height="200"
 445:    * alt="[An illustration of EmptyBorder]" /></p>
 446:    *
 447:    * @author Brian Jones (cbj@gnu.org)
 448:    * @author Sascha Brawer (brawer@dandelis.ch)
 449:    */
 450:   public static class EmptyBorderUIResource 
 451:     extends EmptyBorder
 452:     implements UIResource, Serializable
 453:   {
 454:     private static final long serialVersionUID = -4914187529340071708L;
 455:     
 456:     /**
 457:      * Constructs an empty border given the number of pixels required
 458:      * on each side.
 459:      *
 460:      * @param top the number of pixels that the border will need
 461:      *        for its top edge.
 462:      *
 463:      * @param left the number of pixels that the border will need
 464:      *        for its left edge.
 465:      *
 466:      * @param bottom the number of pixels that the border will need
 467:      *        for its bottom edge.
 468:      *
 469:      * @param right the number of pixels that the border will need
 470:      *        for its right edge.
 471:      */
 472:     public EmptyBorderUIResource(int top, int left, int bottom, int right)
 473:     {
 474:       super(top, left, bottom, right);
 475:     }
 476:     
 477:     
 478:     /**
 479:      * Constructs an empty border given the number of pixels required
 480:      * on each side, passed in an Insets object.
 481:      *
 482:      * @param insets the Insets for the new border.
 483:      */
 484:     public EmptyBorderUIResource(Insets insets)
 485:     {
 486:       super(insets);
 487:     }
 488:   }
 489:   
 490:   
 491:   /**
 492:    * An {@link javax.swing.border.EtchedBorder} that also implements the
 493:    * {@link UIResource} marker interface.  This is useful for
 494:    * implementing pluggable look-and-feels: When switching the current
 495:    * LookAndFeel, only those borders are replaced that are marked as
 496:    * {@link UIResource}.  For this reason, a look-and-feel should
 497:    * always install borders that implement <code>UIResource</code>,
 498:    * such as the borders provided by this class.
 499:    *
 500:    * <p><img src="../border/doc-files/EtchedBorder-1.png" width="500"
 501:    * height="200" alt="[An illustration of the two EtchedBorder
 502:    * variants]" /></p>
 503:    *
 504:    * @author Brian Jones (cbj@gnu.org)
 505:    * @author Sascha Brawer (brawer@dandelis.ch)
 506:    */
 507:   public static class EtchedBorderUIResource
 508:     extends EtchedBorder
 509:     implements UIResource, Serializable
 510:   {
 511:     private static final long serialVersionUID = -8186391754165296656L;
 512:     
 513:     /**
 514:      * Constructs an EtchedBorderUIResource that appears lowered into
 515:      * the surface. The colors will be derived from the background
 516:      * color of the enclosed Component when the border gets painted.
 517:      */
 518:     public EtchedBorderUIResource()
 519:     {
 520:       super();
 521:     }
 522:     
 523:     
 524:     /**
 525:      * Constructs an EtchedBorderUIResource with the specified
 526:      * appearance. The colors will be derived from the background
 527:      * color of the enclosed Component when the border gets painted.
 528:      *
 529:      * <p><img src="../border/doc-files/EtchedBorder-1.png"
 530:      * width="500" height="200" alt="[An illustration of the two
 531:      * EtchedBorder variants]" /></p>
 532:      *
 533:      * @param etchType the desired appearance of the border. The value
 534:      *        must be either {@link javax.swing.border.EtchedBorder#RAISED}
 535:      *        or {@link javax.swing.border.EtchedBorder#LOWERED}.
 536:      *
 537:      * @throws IllegalArgumentException if <code>etchType</code> has
 538:      *         an unsupported value.
 539:      */
 540:     public EtchedBorderUIResource(int etchType) 
 541:     {
 542:       super(etchType);
 543:     }
 544:     
 545:     
 546:     /**
 547:      * Constructs a lowered EtchedBorderUIResource, explicitly
 548:      * selecting the colors that will be used for highlight and
 549:      * shadow.
 550:      *
 551:      * @param highlight the color that will be used for painting
 552:      *        the highlight part of the border.
 553:      *
 554:      * @param shadow the color that will be used for painting
 555:      *        the shadow part of the border.
 556:      *
 557:      * @see EtchedBorderUIResource#EtchedBorderUIResource(int, Color, Color)
 558:      */
 559:     public EtchedBorderUIResource(Color highlight, Color shadow)
 560:     {
 561:       super(highlight, shadow);
 562:     }
 563:     
 564:     
 565:     /**
 566:      * Constructs an EtchedBorderUIResource with the specified
 567:      * appearance, explicitly selecting the colors that will be used
 568:      * for highlight and shadow.
 569:      *
 570:      * <p><img src="../border/doc-files/EtchedBorder-2.png" width="500"
 571:      * height="200" alt="[An illustration that shows which pixels get
 572:      * painted in what color]" /></p>
 573:      *
 574:      * @param etchType the desired appearance of the border. The value
 575:      *        must be either {@link javax.swing.border.EtchedBorder#RAISED}
 576:      *        or {@link javax.swing.border.EtchedBorder#LOWERED}.
 577:      *
 578:      * @param highlight the color that will be used for painting
 579:      *        the highlight part of the border.
 580:      *
 581:      * @param shadow the color that will be used for painting
 582:      *        the shadow part of the border.
 583:      *
 584:      * @throws IllegalArgumentException if <code>etchType</code> has
 585:      *         an unsupported value.
 586:      */
 587:     public EtchedBorderUIResource(int etchType,
 588:                                   Color highlight, Color shadow)
 589:     {
 590:       super(etchType, highlight, shadow);
 591:     }
 592:   }
 593:   
 594:   
 595:   /**
 596:    * A {@link javax.swing.border.LineBorder} that also implements the
 597:    * {@link UIResource} marker interface.  This is useful for
 598:    * implementing pluggable look-and-feels: When switching the current
 599:    * LookAndFeel, only those borders are replaced that are marked as
 600:    * {@link UIResource}.  For this reason, a look-and-feel should
 601:    * always install borders that implement <code>UIResource</code>,
 602:    * such as the borders provided by this class.
 603:    *
 604:    * <p><img src="../border/doc-files/LineBorder-1.png" width="500"
 605:    * height="200" alt="[An illustration of two LineBorders]" /></p>
 606:    *
 607:    * @author Brian Jones (cbj@gnu.org)
 608:    * @author Sascha Brawer (brawer@dandelis.ch)
 609:    */
 610:   public static class LineBorderUIResource
 611:     extends LineBorder
 612:     implements UIResource, Serializable
 613:   {
 614:     private static final long serialVersionUID = -6171232338180172310L;
 615:     
 616:     /**
 617:      * Constructs a LineBorderUIResource given its color.  The border
 618:      * will be one pixel thick and have plain corners.
 619:      *
 620:      * @param color the color for drawing the border.
 621:      */
 622:     public LineBorderUIResource(Color color)
 623:     {
 624:       super(color); 
 625:     }
 626:     
 627:     
 628:     /**
 629:      * Constructs a LineBorder given its color and thickness.  The
 630:      * border will have plain corners.
 631:      *
 632:      * @param color the color for drawing the border.
 633:      * @param thickness the width of the line in pixels.
 634:      */
 635:     public LineBorderUIResource(Color color, int thickness)
 636:     {
 637:       super(color, thickness);
 638:     }
 639:     
 640:     
 641:     /* Note: Since JDK1.3, javax.swing.border.LineBorder also has a
 642:      * constructor which accepts a value for the roundedCorners
 643:      * property. However, as of JDK1.4.1, the LineBorderUIResource
 644:      * subclass does not have a corresponding constructor.
 645:      * 
 646:      * A request for enhancing the Swing API has been filed with Sun:
 647:      * http://developer.java.sun.com/developer/bugParade/bugs/4879999.html
 648:      */
 649:   }
 650: 
 651: 
 652:   /**
 653:    * A {@link javax.swing.border.MatteBorder} that also implements the
 654:    * {@link UIResource} marker interface.  This is useful for
 655:    * implementing pluggable look-and-feels: When switching the current
 656:    * LookAndFeel, only those borders are replaced that are marked as
 657:    * {@link UIResource}.  For this reason, a look-and-feel should
 658:    * always install borders that implement <code>UIResource</code>,
 659:    * such as the borders provided by this class.
 660:    *
 661:    * <p><img src="../border/doc-files/MatteBorder-1.png" width="500"
 662:    * height="150" alt="[An illustration of two MatteBorders]" /></p>
 663:    *
 664:    * @author Brian Jones (cbj@gnu.org)
 665:    * @author Sascha Brawer (brawer@dandelis.ch)
 666:    */
 667:   public static class MatteBorderUIResource
 668:     extends MatteBorder
 669:     implements UIResource, Serializable
 670:   {
 671:     private static final long serialVersionUID = -8107923147541851122L;
 672:     
 673:     /**
 674:      * Constructs a MatteBorderUIResource given the width on each side
 675:      * and a fill color.
 676:      *
 677:      * <p><img src="../border/doc-files/MatteBorder-2.png" width="500"
 678:      * height="150" alt="[A picture of a MatteBorder made by this
 679:      * constructor]" /></p>
 680:      *
 681:      * @param top the width of the border at its top edge.
 682:      * @param left the width of the border at its left edge.
 683:      * @param bottom the width of the border at its bottom edge.
 684:      * @param right the width of the border at its right edge.
 685:      * @param color the color for filling the border.
 686:      */
 687:     public MatteBorderUIResource(int top, int left,
 688:                                  int bottom, int right,
 689:                                  Color color)
 690:     {
 691:       super(top, left, bottom, right, color);
 692:     }
 693:     
 694:     
 695:     /**
 696:      * Constructs a MatteBorderUIResource given the width on each side
 697:      * and an icon for tiling the border area.
 698:      *
 699:      * <p><img src="../border/doc-files/MatteBorder-4.png" width="500"
 700:      * height="150" alt="[A picture of a MatteBorder made by this
 701:      * constructor]" /></p>
 702:      *
 703:      * @param top the width of the border at its top edge.
 704:      * @param left the width of the border at its left edge.
 705:      * @param bottom the width of the border at its bottom edge.
 706:      * @param right the width of the border at its right edge.
 707:      * @param tileIcon an icon for tiling the border area.
 708:      */
 709:     public MatteBorderUIResource(int top, int left,
 710:                                  int bottom, int right,
 711:                                  Icon tileIcon)
 712:     {
 713:       super(top, left, bottom, right, tileIcon);
 714:     }
 715:     
 716:     
 717:     /**
 718:      * Constructs a MatteBorderUIResource given an icon for tiling the
 719:      * border area. The icon width is used for the border insets at
 720:      * the left and right edge, the icon height for the top and bottom
 721:      * edge.
 722:      *
 723:      * <p><img src="../border/doc-files/MatteBorder-6.png" width="500"
 724:      * height="150" alt="[A picture of a MatteBorder made by this
 725:      * constructor]" /></p>
 726:      *
 727:      * @param tileIcon an icon for tiling the border area. 
 728:      */
 729:     public MatteBorderUIResource(Icon tileIcon)
 730:     {
 731:       super(tileIcon);
 732:     }
 733:   }
 734:   
 735:   
 736:   /**
 737:    * A {@link javax.swing.border.TitledBorder} that also implements the
 738:    * {@link UIResource} marker interface.  This is useful for
 739:    * implementing pluggable look-and-feels: When switching the current
 740:    * LookAndFeel, only those borders are replaced that are marked as
 741:    * {@link UIResource}.  For this reason, a look-and-feel should
 742:    * always install borders that implement <code>UIResource</code>,
 743:    * such as the borders provided by this class.
 744:    *
 745:    * @author Brian Jones (cbj@gnu.org)
 746:    * @author Sascha Brawer (brawer@dandelis.ch)
 747:    */
 748:   public static class TitledBorderUIResource
 749:     extends TitledBorder
 750:     implements UIResource, Serializable
 751:   {
 752:     private static final long serialVersionUID = 7667113547406407427L;
 753:     
 754:     /**
 755:      * Constructs a TitledBorderUIResource given the text of its title.
 756:      *
 757:      * @param title the title text, or <code>null</code> to use no
 758:      *        title text.
 759:      */
 760:     public TitledBorderUIResource(String title)
 761:     {
 762:       super(title);
 763:     }
 764:     
 765:     
 766:     /**
 767:      * Constructs an initially untitled TitledBorderUIResource
 768:      * given another border.
 769:      *
 770:      * @param border the border underneath the title, or
 771:      *        <code>null</code> to use a default from
 772:      *        the current look and feel.
 773:      */
 774:     public TitledBorderUIResource(Border border)
 775:     {
 776:       super(border);
 777:     }
 778:     
 779:     
 780:     /**
 781:      * Constructs a TitledBorder given its border and title text.
 782:      *
 783:      * @param border the border underneath the title, or
 784:      *        <code>null</code> to use a default from
 785:      *        the current look and feel.
 786:      *
 787:      * @param title the title text, or <code>null</code>
 788:      *        to use no title text.
 789:      */
 790:     public TitledBorderUIResource(Border border, String title)
 791:     {
 792:       super(border, title);
 793:     }
 794: 
 795: 
 796:     /**
 797:      * Constructs a TitledBorderUIResource given its border, title
 798:      * text, horizontal alignment, and vertical position.
 799:      *
 800:      * @param border the border underneath the title, or
 801:      *        <code>null</code> to use a default
 802:      *        from the current look and feel.
 803:      *
 804:      * @param title the title text, or <code>null</code>
 805:      *        to use no title text.
 806:      *
 807:      * @param titleJustification the horizontal alignment of the title
 808:      *        text in relation to the border. The value must be one of
 809:      *        {@link javax.swing.border.TitledBorder#LEFT},
 810:      *        {@link javax.swing.border.TitledBorder#CENTER},
 811:      *        {@link javax.swing.border.TitledBorder#RIGHT},
 812:      *        {@link javax.swing.border.TitledBorder#LEADING},
 813:      *        {@link javax.swing.border.TitledBorder#TRAILING}, or
 814:      *        {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
 815:      *
 816:      * @param titlePosition the vertical position of the title text
 817:      *        in relation to the border. The value must be one of
 818:      *        {@link javax.swing.border.TitledBorder#ABOVE_TOP},
 819:      *        {@link javax.swing.border.TitledBorder#TOP},
 820:      *        {@link javax.swing.border.TitledBorder#BELOW_TOP},
 821:      *        {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
 822:      *        {@link javax.swing.border.TitledBorder#BOTTOM},
 823:      *        {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
 824:      *        or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
 825:      *
 826:      * @throws IllegalArgumentException if <code>titleJustification</code>
 827:      *         or <code>titlePosition</code> have an unsupported value.
 828:      */
 829:     public TitledBorderUIResource(Border border, String title,
 830:                                   int titleJustification,
 831:                                   int titlePosition)
 832:     {
 833:       super(border, title, titleJustification, titlePosition);
 834:     }
 835: 
 836: 
 837:     /**
 838:      * Constructs a TitledBorder given its border, title text,
 839:      * horizontal alignment, vertical position, and font.
 840:      *
 841:      * @param border the border underneath the title, or
 842:      *        <code>null</code> to use a default
 843:      *        from the current look and feel.
 844:      *
 845:      * @param title the title text, or <code>null</code>
 846:      *        to use no title text.
 847:      *
 848:      * @param titleJustification the horizontal alignment of the title
 849:      *        text in relation to the border. The value must be one of
 850:      *        {@link javax.swing.border.TitledBorder#LEFT},
 851:      *        {@link javax.swing.border.TitledBorder#CENTER},
 852:      *        {@link javax.swing.border.TitledBorder#RIGHT},
 853:      *        {@link javax.swing.border.TitledBorder#LEADING},
 854:      *        {@link javax.swing.border.TitledBorder#TRAILING}, or
 855:      *        {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
 856:      *
 857:      * @param titlePosition the vertical position of the title text
 858:      *        in relation to the border. The value must be one of
 859:      *        {@link javax.swing.border.TitledBorder#ABOVE_TOP},
 860:      *        {@link javax.swing.border.TitledBorder#TOP},
 861:      *        {@link javax.swing.border.TitledBorder#BELOW_TOP},
 862:      *        {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
 863:      *        {@link javax.swing.border.TitledBorder#BOTTOM},
 864:      *        {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
 865:      *        or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
 866:      *
 867:      * @param titleFont the font for the title text, or <code>null</code>
 868:      *        to use a default from the current look and feel.
 869:      *
 870:      * @throws IllegalArgumentException if <code>titleJustification</code>
 871:      *         or <code>titlePosition</code> have an unsupported value.
 872:      */
 873:     public TitledBorderUIResource(Border border, String title,
 874:                                   int titleJustification,
 875:                                   int titlePosition,
 876:                                   Font titleFont)
 877:     {
 878:       super(border, title, titleJustification, titlePosition,
 879:             titleFont);
 880:     }
 881:     
 882:     
 883:     /**
 884:      * Constructs a TitledBorder given its border, title text,
 885:      * horizontal alignment, vertical position, font, and color.
 886:      *
 887:      * @param border the border underneath the title, or
 888:      *        <code>null</code> to use a default
 889:      *        from the current look and feel.
 890:      *
 891:      * @param title the title text, or <code>null</code>
 892:      *        to use no title text.
 893:      *
 894:      * @param titleJustification the horizontal alignment of the title
 895:      *        text in relation to the border. The value must be one of
 896:      *        {@link javax.swing.border.TitledBorder#LEFT},
 897:      *        {@link javax.swing.border.TitledBorder#CENTER},
 898:      *        {@link javax.swing.border.TitledBorder#RIGHT},
 899:      *        {@link javax.swing.border.TitledBorder#LEADING},
 900:      *        {@link javax.swing.border.TitledBorder#TRAILING}, or
 901:      *        {@link javax.swing.border.TitledBorder#DEFAULT_JUSTIFICATION}.
 902:      *
 903:      * @param titlePosition the vertical position of the title text
 904:      *        in relation to the border. The value must be one of
 905:      *        {@link javax.swing.border.TitledBorder#ABOVE_TOP},
 906:      *        {@link javax.swing.border.TitledBorder#TOP},
 907:      *        {@link javax.swing.border.TitledBorder#BELOW_TOP},
 908:      *        {@link javax.swing.border.TitledBorder#ABOVE_BOTTOM},
 909:      *        {@link javax.swing.border.TitledBorder#BOTTOM},
 910:      *        {@link javax.swing.border.TitledBorder#BELOW_BOTTOM},
 911:      *        or {@link javax.swing.border.TitledBorder#DEFAULT_POSITION}.
 912:      *
 913:      * @param titleFont the font for the title text, or <code>null</code>
 914:      *        to use a default from the current look and feel.
 915:      *
 916:      * @param titleColor the color for the title text, or <code>null</code>
 917:      *        to use a default from the current look and feel.
 918:      *
 919:      * @throws IllegalArgumentException if <code>titleJustification</code>
 920:      *         or <code>titlePosition</code> have an unsupported value.
 921:      */
 922:     public TitledBorderUIResource(Border border, String title,
 923:                                   int titleJustification, int titlePosition,
 924:                                   Font titleFont, Color titleColor)
 925:     {
 926:       super(border, title, titleJustification, titlePosition,
 927:             titleFont, titleColor);
 928:     }
 929:   }
 930: }