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