Source for javax.swing.plaf.metal.MetalLookAndFeel

   1: /* MetalLookAndFeel.java
   2:    Copyright (C) 2002, 2005 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.metal;
  40: 
  41: import java.awt.Color;
  42: import java.awt.Font;
  43: import java.awt.Insets;
  44: 
  45: import javax.swing.UIDefaults;
  46: import javax.swing.plaf.BorderUIResource;
  47: import javax.swing.plaf.ColorUIResource;
  48: import javax.swing.plaf.FontUIResource;
  49: import javax.swing.plaf.InsetsUIResource;
  50: import javax.swing.plaf.basic.BasicLookAndFeel;
  51: 
  52: 
  53: /**
  54:  * A custom look and feel that is designed to look similar across different
  55:  * operating systems.
  56:  */
  57: public class MetalLookAndFeel extends BasicLookAndFeel
  58: {       
  59:   private static final long serialVersionUID = 6680646159193457980L;
  60:   
  61:   /** The current theme. */
  62:   private static MetalTheme theme;
  63:   
  64:   /** The look and feel defaults. */
  65:   private UIDefaults LAF_defaults;
  66: 
  67:   /**
  68:    * Creates a new instance of the Metal look and feel.
  69:    */
  70:   public MetalLookAndFeel()
  71:   {
  72:     createDefaultTheme();
  73:   }
  74: 
  75:   /**
  76:    * Sets the current theme to a new instance of {@link DefaultMetalTheme}.
  77:    */
  78:   protected void createDefaultTheme()
  79:   {
  80:     setCurrentTheme(new DefaultMetalTheme());
  81:   }
  82: 
  83:   /**
  84:    * Returns <code>false</code> to indicate that this look and feel does not
  85:    * attempt to emulate the look and feel of native applications on the host
  86:    * platform.
  87:    * 
  88:    * @return <code>false</code>.
  89:    */
  90:   public boolean isNativeLookAndFeel()
  91:   {
  92:     return false;
  93:   }
  94: 
  95:   /**
  96:    * Returns <code>true</code> to indicate that this look and feel is supported
  97:    * on all platforms.
  98:    * 
  99:    * @return <code>true</code>.
 100:    */
 101:   public boolean isSupportedLookAndFeel()
 102:   {
 103:     return true;
 104:   }
 105: 
 106:   /**
 107:    * Returns a string describing the look and feel.  In this case, the method
 108:    * returns "Metal look and feel".
 109:    * 
 110:    * @return A string describing the look and feel.
 111:    */
 112:   public String getDescription()
 113:   {
 114:     return "Metal look and feel";
 115:   }
 116: 
 117:   /**
 118:    * Returns the look and feel identifier.
 119:    * 
 120:    * @return "MetalLookAndFeel".
 121:    */
 122:   public String getID()
 123:   {
 124:     return "MetalLookAndFeel";
 125:   }
 126: 
 127:   /**
 128:    * Returns the look and feel name.
 129:    * 
 130:    * @return "MetalLookAndFeel".
 131:    */
 132:   public String getName()
 133:   {
 134:     return "MetalLookAndFeel";
 135:   }
 136: 
 137:   public UIDefaults getDefaults()
 138:   {
 139:     if (LAF_defaults == null)
 140:       {
 141:         LAF_defaults = super.getDefaults();
 142: 
 143:         // add custom theme entries to the table
 144:         theme.addCustomEntriesToTable(LAF_defaults);
 145:       }
 146:     
 147:     // Returns the default values for this look and feel. 
 148:     return LAF_defaults;
 149:   }
 150: 
 151:   /**
 152:    * Returns the accelerator foreground color from the installed theme.
 153:    * 
 154:    * @return The accelerator foreground color.
 155:    */
 156:   public static ColorUIResource getAcceleratorForeground()
 157:   {
 158:     return theme.getAcceleratorForeground();
 159:   }
 160: 
 161:   /**
 162:    * Returns the accelerator selected foreground color from the installed 
 163:    * theme.
 164:    * 
 165:    * @return The accelerator selected foreground color.
 166:    */
 167:   public static ColorUIResource getAcceleratorSelectedForeground()
 168:   {
 169:     return theme.getAcceleratorSelectedForeground();
 170:   }
 171: 
 172:   /**
 173:    * Returns the color black from the installed theme.
 174:    * 
 175:    * @return The color black.
 176:    */
 177:   public static ColorUIResource getBlack()
 178:   {
 179:     return theme.getBlack();
 180:   }
 181: 
 182:   /**
 183:    * Returns the control color from the installed theme.
 184:    * 
 185:    * @return The control color.
 186:    */
 187:   public static ColorUIResource getControl()
 188:   {
 189:     return theme.getControl();
 190:   }
 191: 
 192:   /**
 193:    * Returns the color used for dark shadows on controls, from the installed
 194:    * theme.
 195:    * 
 196:    * @return The color used for dark shadows on controls.
 197:    */
 198:   public static ColorUIResource getControlDarkShadow()
 199:   {
 200:     return theme.getControlDarkShadow();
 201:   }
 202: 
 203:   /**
 204:    * Returns the color used for disabled controls, from the installed theme.
 205:    * 
 206:    * @return The color used for disabled controls.
 207:    */
 208:   public static ColorUIResource getControlDisabled()
 209:   {
 210:     return theme.getControlDisabled();
 211:   }
 212: 
 213:   /**
 214:    * Returns the color used to draw highlights for controls, from the installed
 215:    * theme.
 216:    * 
 217:    * @return The color used to draw highlights for controls.
 218:    */
 219:   public static ColorUIResource getControlHighlight()
 220:   {
 221:     return theme.getControlHighlight();
 222:   }
 223: 
 224:   /**
 225:    * Returns the color used to display control info, from the installed 
 226:    * theme.
 227:    * 
 228:    * @return The color used to display control info.
 229:    */
 230:   public static ColorUIResource getControlInfo()
 231:   {
 232:     return theme.getControlInfo();
 233:   }
 234: 
 235:   /**
 236:    * Returns the color used to draw shadows for controls, from the installed
 237:    * theme.
 238:    * 
 239:    * @return The color used to draw shadows for controls.
 240:    */
 241:   public static ColorUIResource getControlShadow()
 242:   {
 243:     return theme.getControlShadow();
 244:   }
 245: 
 246:   /**
 247:    * Returns the color used for text on controls, from the installed theme.
 248:    * 
 249:    * @return The color used for text on controls.
 250:    */
 251:   public static ColorUIResource getControlTextColor()
 252:   {
 253:     return theme.getControlTextColor();
 254:   }
 255: 
 256:   /**
 257:    * Returns the font used for text on controls, from the installed theme.
 258:    * 
 259:    * @return The font used for text on controls.
 260:    */
 261:   public static FontUIResource getControlTextFont()
 262:   {
 263:     return theme.getControlTextFont();
 264:   }
 265: 
 266:   /**
 267:    * Returns the color used for the desktop background, from the installed 
 268:    * theme.
 269:    * 
 270:    * @return The color used for the desktop background.
 271:    */
 272:   public static ColorUIResource getDesktopColor()
 273:   {
 274:     return theme.getDesktopColor();
 275:   }
 276: 
 277:   /**
 278:    * Returns the color used to draw focus highlights, from the installed 
 279:    * theme.
 280:    * 
 281:    * @return The color used to draw focus highlights.
 282:    */
 283:   public static ColorUIResource getFocusColor()
 284:   {
 285:     return theme.getFocusColor();
 286:   }
 287: 
 288:   /**
 289:    * Returns the color used to draw highlighted text, from the installed
 290:    * theme.
 291:    * 
 292:    * @return The color used to draw highlighted text.
 293:    */
 294:   public static ColorUIResource getHighlightedTextColor()
 295:   {
 296:     return theme.getHighlightedTextColor();
 297:   }
 298: 
 299:   /**
 300:    * Returns the color used to draw text on inactive controls, from the
 301:    * installed theme.
 302:    * 
 303:    * @return The color used to draw text on inactive controls.
 304:    */
 305:   public static ColorUIResource getInactiveControlTextColor()
 306:   {
 307:     return theme.getInactiveControlTextColor();
 308:   }
 309: 
 310:   /**
 311:    * Returns the color used to draw inactive system text, from the installed
 312:    * theme.
 313:    * 
 314:    * @return The color used to draw inactive system text.
 315:    */
 316:   public static ColorUIResource getInactiveSystemTextColor()
 317:   {
 318:     return theme.getInactiveSystemTextColor();
 319:   }
 320: 
 321:   /**
 322:    * Returns the background color for menu items, from the installed theme.
 323:    * 
 324:    * @return The background color for menu items.
 325:    * 
 326:    * @see #getMenuSelectedBackground()
 327:    */
 328:   public static ColorUIResource getMenuBackground()
 329:   {
 330:     return theme.getMenuBackground();
 331:   }
 332: 
 333:   /**
 334:    * Returns the foreground color for disabled menu items, from the installed
 335:    * theme.
 336:    * 
 337:    * @return The foreground color for disabled menu items.
 338:    * 
 339:    * @see #getMenuForeground()
 340:    */
 341:   public static ColorUIResource getMenuDisabledForeground()
 342:   {
 343:     return theme.getMenuDisabledForeground();
 344:   }
 345: 
 346:   /**
 347:    * Returns the foreground color for menu items, from the installed theme.
 348:    * 
 349:    * @return The foreground color for menu items.
 350:    * 
 351:    * @see #getMenuDisabledForeground()
 352:    * @see #getMenuSelectedForeground()
 353:    */
 354:   public static ColorUIResource getMenuForeground()
 355:   {
 356:     return theme.getMenuForeground();
 357:   }
 358: 
 359:   /**
 360:    * Returns the background color for selected menu items, from the installed
 361:    * theme.
 362:    * 
 363:    * @return The background color for selected menu items.
 364:    * 
 365:    * @see #getMenuBackground()
 366:    */
 367:   public static ColorUIResource getMenuSelectedBackground()
 368:   {
 369:     return theme.getMenuSelectedBackground();
 370:   }
 371: 
 372:   /**
 373:    * Returns the foreground color for selected menu items, from the installed
 374:    * theme.
 375:    * 
 376:    * @return The foreground color for selected menu items.
 377:    * 
 378:    * @see #getMenuForeground()
 379:    */
 380:   public static ColorUIResource getMenuSelectedForeground()
 381:   {
 382:     return theme.getMenuSelectedForeground();
 383:   }
 384: 
 385:   /**
 386:    * Returns the font used for text in menus, from the installed theme.
 387:    * 
 388:    * @return The font used for text in menus.
 389:    */
 390:   public static FontUIResource getMenuTextFont()
 391:   {
 392:     return theme.getMenuTextFont();
 393:   }
 394: 
 395:   /**
 396:    * Returns the primary color for controls, from the installed theme.
 397:    * 
 398:    * @return The primary color for controls.
 399:    */
 400:   public static ColorUIResource getPrimaryControl()
 401:   {
 402:     return theme.getPrimaryControl();
 403:   }
 404: 
 405:   /**
 406:    * Returns the primary color for the dark shadow on controls, from the 
 407:    * installed theme.
 408:    * 
 409:    * @return The primary color for the dark shadow on controls.
 410:    */
 411:   public static ColorUIResource getPrimaryControlDarkShadow()
 412:   {
 413:     return theme.getPrimaryControlDarkShadow();
 414:   }
 415: 
 416:   /**
 417:    * Returns the primary color for the highlight on controls, from the 
 418:    * installed theme.
 419:    * 
 420:    * @return The primary color for the highlight on controls.
 421:    */
 422:   public static ColorUIResource getPrimaryControlHighlight()
 423:   {
 424:     return theme.getPrimaryControlHighlight();
 425:   }
 426: 
 427:   /**
 428:    * Returns the primary color for the information on controls, from the 
 429:    * installed theme.
 430:    * 
 431:    * @return The primary color for the information on controls.
 432:    */
 433:   public static ColorUIResource getPrimaryControlInfo()
 434:   {
 435:     return theme.getPrimaryControlInfo();
 436:   }
 437: 
 438:   /**
 439:    * Returns the primary color for the shadow on controls, from the installed
 440:    * theme.
 441:    * 
 442:    * @return The primary color for the shadow on controls.
 443:    */
 444:   public static ColorUIResource getPrimaryControlShadow()
 445:   {
 446:     return theme.getPrimaryControlShadow();
 447:   }
 448: 
 449:   /**
 450:    * Returns the background color for separators, from the installed theme.
 451:    * 
 452:    * @return The background color for separators.
 453:    */
 454:   public static ColorUIResource getSeparatorBackground()
 455:   {
 456:     return theme.getSeparatorBackground();
 457:   }
 458: 
 459:   /**
 460:    * Returns the foreground color for separators, from the installed theme.
 461:    * 
 462:    * @return The foreground color for separators.
 463:    */
 464:   public static ColorUIResource getSeparatorForeground()
 465:   {
 466:     return theme.getSeparatorForeground();
 467:   }
 468: 
 469:   /**
 470:    * Returns the font used for sub text, from the installed theme.
 471:    * 
 472:    * @return The font used for sub text.
 473:    */
 474:   public static FontUIResource getSubTextFont()
 475:   {
 476:     return theme.getSubTextFont();
 477:   }
 478: 
 479:   /**
 480:    * Returns the color used for system text, from the installed theme.
 481:    * 
 482:    * @return The color used for system text.
 483:    */
 484:   public static ColorUIResource getSystemTextColor()
 485:   {
 486:     return theme.getSystemTextColor();
 487:   }
 488: 
 489:   /**
 490:    * Returns the font used for system text, from the installed theme.
 491:    * 
 492:    * @return The font used for system text.
 493:    */
 494:   public static FontUIResource getSystemTextFont()
 495:   {
 496:     return theme.getSystemTextFont();
 497:   }
 498: 
 499:   /**
 500:    * Returns the color used to highlight text, from the installed theme.
 501:    * 
 502:    * @return The color used to highlight text.
 503:    */
 504:   public static ColorUIResource getTextHighlightColor()
 505:   {
 506:     return theme.getTextHighlightColor();
 507:   }
 508: 
 509:   /**
 510:    * Returns the color used to display user text, from the installed theme.
 511:    * 
 512:    * @return The color used to display user text.
 513:    */
 514:   public static ColorUIResource getUserTextColor()
 515:   {
 516:     return theme.getUserTextColor();
 517:   }
 518: 
 519:   /**
 520:    * Returns the font used for user text, obtained from the current theme.
 521:    * 
 522:    * @return The font used for user text.
 523:    */
 524:   public static FontUIResource getUserTextFont()
 525:   {
 526:     return theme.getUserTextFont();
 527:   }
 528: 
 529:   /**
 530:    * Returns the color used for white, from the installed theme.
 531:    * 
 532:    * @return The color used for white.
 533:    */
 534:   public static ColorUIResource getWhite()
 535:   {
 536:     return theme.getWhite();
 537:   }
 538: 
 539:   /**
 540:    * Returns the window background color, from the installed theme.
 541:    * 
 542:    * @return The window background color.
 543:    */
 544:   public static ColorUIResource getWindowBackground()
 545:   {
 546:     return theme.getWindowBackground();
 547:   }
 548: 
 549:   /**
 550:    * Returns the window title background color, from the installed theme.
 551:    * 
 552:    * @return The window title background color.
 553:    */
 554:   public static ColorUIResource getWindowTitleBackground()
 555:   {
 556:     return theme.getWindowTitleBackground();
 557:   }
 558: 
 559:   /**
 560:    * Returns the window title font from the current theme.
 561:    * 
 562:    * @return The window title font.
 563:    * 
 564:    * @see MetalTheme
 565:    */
 566:   public static FontUIResource getWindowTitleFont()
 567:   {
 568:     return theme.getWindowTitleFont();
 569:   }
 570: 
 571:   /**
 572:    * Returns the window title foreground color, from the installed theme.
 573:    * 
 574:    * @return The window title foreground color.
 575:    */
 576:   public static ColorUIResource getWindowTitleForeground()
 577:   {
 578:     return theme.getWindowTitleForeground();
 579:   }
 580: 
 581:   /**
 582:    * Returns the background color for an inactive window title, from the 
 583:    * installed theme.
 584:    * 
 585:    * @return The background color for an inactive window title.
 586:    */
 587:   public static ColorUIResource getWindowTitleInactiveBackground()
 588:   {
 589:     return theme.getWindowTitleInactiveBackground();
 590:   }
 591: 
 592:   /**
 593:    * Returns the foreground color for an inactive window title, from the 
 594:    * installed theme.
 595:    * 
 596:    * @return The foreground color for an inactive window title.
 597:    */
 598:   public static ColorUIResource getWindowTitleInactiveForeground()
 599:   {
 600:     return theme.getWindowTitleInactiveForeground();
 601:   }
 602: 
 603:   /**
 604:    * Sets the current theme for the look and feel.
 605:    * 
 606:    * @param theme  the theme.
 607:    */
 608:   public static void setCurrentTheme(MetalTheme theme)
 609:   {
 610:     MetalLookAndFeel.theme = theme;
 611:   }
 612: 
 613:   /**
 614:    * Sets the ComponentUI classes for all Swing components to the Metal
 615:    * implementations.
 616:    *
 617:    * In particular this sets the following keys:
 618:    *
 619:    * <table>
 620:    * <tr>
 621:    * <th>Key</th><th>Value</th>
 622:    * </tr><tr>
 623:    * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
 624:    * </tr><tr>
 625:    * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
 626:    * </tr><tr>
 627:    * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
 628:    * </tr><tr>
 629:    * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
 630:    * </tr><tr>
 631:    * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
 632:    * </tr><tr>
 633:    * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
 634:    * </tr><tr>
 635:    * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
 636:    * </tr><tr>
 637:    * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
 638:    * </tr><tr>
 639:    * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
 640:    * </tr><tr>
 641:    * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
 642:    * </tr><tr>
 643:    * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
 644:    * </tr><tr>
 645:    * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
 646:    * </tr><tr>
 647:    * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
 648:    * </tr><tr>
 649:    * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
 650:    * </tr><tr>
 651:    * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
 652:    * </tr><tr>
 653:    * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
 654:    * </tr><tr>
 655:    * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
 656:    * </tr><tr>
 657:    * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
 658:    * </tr><tr>
 659:    * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
 660:    * </tr><tr>
 661:    * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
 662:    * </tr><tr>
 663:    * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
 664:    * </tr><tr>
 665:    * </table>
 666:    *
 667:    * @param defaults the UIDefaults where the class defaults are added
 668:    */
 669:   protected void initClassDefaults(UIDefaults defaults)
 670:   {
 671:     super.initClassDefaults(defaults);
 672: 
 673:     // Variables
 674:     Object[] uiDefaults;
 675:     // Initialize Class Defaults
 676:     uiDefaults = new Object[] {
 677:       "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
 678:       "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
 679:       "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
 680:       "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
 681:       "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
 682:       "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
 683:       "PopupMenuSeparatorUI",
 684:       "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
 685:       "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
 686:       "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
 687:       "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
 688:       "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
 689:       "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
 690:       "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
 691:       "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
 692:       "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
 693:       "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
 694:       "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
 695:       "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
 696:       "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
 697:       "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
 698:       "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
 699:     };
 700:     // Add Class Defaults to UI Defaults table
 701:     defaults.putDefaults(uiDefaults);
 702:   }
 703: 
 704:   /**
 705:    * Initializes the component defaults for the Metal Look &amp; Feel.
 706:    *
 707:    * In particular this sets the following keys (the colors are given
 708:    * as RGB hex values):
 709:    *
 710:    * <table>
 711:    * <tr>
 712:    * <th>Key</th><th>Value</th>
 713:    * </tr><tr>
 714:    * <td>Button.background</td><td>0xcccccc</td>
 715:    * </tr><tr>
 716:    * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
 717:    * </tr><tr>
 718:    * <td>Button.font</td><td>{@link #getControlTextFont}</td>
 719:    * </tr><tr>
 720:    * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
 721:    * </td>
 722:    * </tr><tr>
 723:    * <td>CheckBox.background</td><td>0xcccccc</td>
 724:    * </tr><tr>
 725:    * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
 726:    * </tr><tr>
 727:    * <td>ToolBar.background</td><td>0xcccccc</td>
 728:    * </tr><tr>
 729:    * <td>Panel.background</td><td>0xcccccc</td>
 730:    * </tr><tr>
 731:    * <td>Slider.background</td><td>0xcccccc</td>
 732:    * </tr><tr>
 733:    * <td>OptionPane.background</td><td>0xcccccc</td>
 734:    * </tr><tr>
 735:    * <td>ProgressBar.background</td><td>0xcccccc</td>
 736:    * </tr><tr>
 737:    * <td>TabbedPane.background</td><td>0xcccccc</td>
 738:    * </tr><tr>
 739:    * <td>Label.background</td><td>0xcccccc</td>
 740:    * </tr><tr>
 741:    * <td>Label.font</td><td>{@link #getControlTextFont}</td>
 742:    * </tr><tr>
 743:    * <td>Menu.background</td><td>0xcccccc</td>
 744:    * </tr><tr>
 745:    * <td>MenuBar.background</td><td>0xcccccc</td>
 746:    * </tr><tr>
 747:    * <td>MenuItem.background</td><td>0xcccccc</td>
 748:    * </tr><tr>
 749:    * <td>ScrollBar.background</td><td>0xcccccc</td>
 750:    * </tr><tr>
 751:    * <td>PopupMenu.border</td>
 752:    * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
 753:    * </tr><tr>
 754:    * </table>
 755:    *
 756:    * @param defaults the UIDefaults instance to which the values are added
 757:    */
 758:   protected void initComponentDefaults(UIDefaults defaults)
 759:   {
 760:     super.initComponentDefaults(defaults);
 761:     Object[] myDefaults = new Object[] {
 762:       "Button.background", new ColorUIResource(getControl()),
 763:       "Button.border", MetalBorders.getButtonBorder(),
 764:       "Button.darkShadow", new ColorUIResource(getControlDarkShadow()),
 765:       "Button.disabledText", new ColorUIResource(getControlDisabled()),
 766:       "Button.focus", new ColorUIResource(getFocusColor()),
 767:       "Button.font", getControlTextFont(),
 768:       "Button.foreground", new ColorUIResource(getSystemTextColor()),
 769:       "Button.highlight", new ColorUIResource(getControlHighlight()),
 770:       "Button.light", new ColorUIResource(getControlHighlight()),
 771:       "Button.margin", new Insets(2, 14, 2, 14),
 772:       "Button.select", new ColorUIResource(getPrimaryControlShadow()),
 773:       "Button.shadow", new ColorUIResource(getPrimaryControlShadow()),
 774:       "CheckBox.background", new ColorUIResource(getControl()),
 775:       "CheckBox.border", MetalBorders.getButtonBorder(),
 776:       "CheckBox.icon",
 777:       new UIDefaults.ProxyLazyValue
 778:           ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
 779:       "CheckBox.checkIcon",
 780:       new UIDefaults.ProxyLazyValue
 781:       ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
 782:       "CheckBoxMenuItem.background", new ColorUIResource(getControl()),
 783:       "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
 784:       "ToolBar.background", new ColorUIResource(getControl()),
 785:       "Panel.background", new ColorUIResource(getControl()),
 786:       "Slider.background", new ColorUIResource(getControl()),
 787:       "OptionPane.background", new ColorUIResource(getControl()),
 788:       "ProgressBar.background", new ColorUIResource(getControl()),
 789:       "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
 790:       "TabbedPane.background", new ColorUIResource(getControl()),
 791:       "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
 792:       "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
 793:       "InternalFrame.closeIcon", 
 794:         MetalIconFactory.getInternalFrameCloseIcon(16),
 795:       "InternalFrame.maximizeIcon", 
 796:         MetalIconFactory.getInternalFrameMaximizeIcon(16),
 797:       "InternalFrame.iconifyIcon", 
 798:         MetalIconFactory.getInternalFrameMinimizeIcon(16),
 799:       "Label.background", new ColorUIResource(getControl()),
 800:       "Label.font", getControlTextFont(),
 801:       "Label.disabledForeground", new ColorUIResource(getInactiveControlTextColor()),
 802:       "Label.foreground", new ColorUIResource(getControlTextColor()),
 803:       "Menu.background", new ColorUIResource(getControl()),
 804:       "Menu.border", new MetalBorders.MenuItemBorder(),
 805:       "Menu.borderPainted", Boolean.TRUE,
 806:       "Menu.font", getControlTextFont(),
 807:       "Menu.selectionBackground", getMenuSelectedBackground(),
 808:       "Menu.selectionForeground", getMenuSelectedForeground(),
 809:       "MenuBar.background", new ColorUIResource(getControl()),
 810:       "MenuBar.border", new MetalBorders.MenuBarBorder(),
 811:       "MenuBar.font", getControlTextFont(),
 812:       "MenuItem.background", new ColorUIResource(getControl()),
 813:       "MenuItem.border", new MetalBorders.MenuItemBorder(),
 814:       "MenuItem.font", getControlTextFont(),
 815:       "MenuItem.selectionBackground", getMenuSelectedBackground(),
 816:       "MenuItem.selectionForeground", getMenuSelectedForeground(),
 817:       "Panel.background", new ColorUIResource(getControl()),
 818:       "RadioButton.icon",
 819:       new UIDefaults.LazyValue()
 820:       {
 821:         public Object createValue(UIDefaults def)
 822:           {
 823:             return MetalIconFactory.getRadioButtonIcon();
 824:           }
 825:       },
 826: 
 827:       "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
 828:       "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
 829:       "RadioButtonMenuItem.checkIcon", 
 830:         MetalIconFactory.getRadioButtonMenuItemIcon(),
 831:       "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
 832:       "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
 833:       "RadioButtonMenuItem.selectionBackground", 
 834:         MetalLookAndFeel.getMenuSelectedBackground(),
 835:       "RadioButtonMenuItem.selectionForeground", 
 836:         MetalLookAndFeel.getMenuSelectedForeground(),
 837: 
 838:       "ScrollBar.background", new ColorUIResource(getControl()),
 839:       "ScrollBar.shadow", new ColorUIResource(getControlShadow()),
 840:       "ScrollBar.thumb", new ColorUIResource(getPrimaryControlShadow()),
 841:       "ScrollBar.thumbDarkShadow",
 842:       new ColorUIResource(getPrimaryControlDarkShadow()),
 843:       "ScrollBar.thumbHighlight",
 844:       new ColorUIResource(getPrimaryControl()),
 845: 
 846:       "SplitPane.darkShadow",
 847:       new ColorUIResource(getControlDarkShadow()),
 848:       "SplitPane.highlight",
 849:       new ColorUIResource(getControlHighlight()),
 850: 
 851:       "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
 852:       "Slider.horizontalThumbIcon", 
 853:       MetalIconFactory.getHorizontalSliderThumbIcon(),
 854:       "Slider.verticalThumbIcon", 
 855:       MetalIconFactory.getVerticalSliderThumbIcon(),
 856:       "Slider.trackWidth", new Integer(7),
 857:       "Slider.majorTickLength", new Integer(6),
 858:       
 859:       "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
 860:       "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
 861:       "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
 862:       "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6),
 863: 
 864:       "ToggleButton.background", new ColorUIResource(getControl()),
 865:       "ToggleButton.border", MetalBorders.getButtonBorder(),
 866:       "ToggleButton.darkShadow", new ColorUIResource(getControlDarkShadow()),
 867:       "ToggleButton.disabledText", new ColorUIResource(getControlDisabled()),
 868:       "ToggleButton.focus", new ColorUIResource(getFocusColor()),
 869:       "ToggleButton.font", getControlTextFont(),
 870:       "ToggleButton.foreground", new ColorUIResource(getSystemTextColor()),
 871:       "ToggleButton.highlight", new ColorUIResource(getControlHighlight()),
 872:       "ToggleButton.light", new ColorUIResource(getControlHighlight()),
 873:       "ToggleButton.margin", new Insets(2, 14, 2, 14),
 874:       "ToggleButton.select", new ColorUIResource(getPrimaryControlShadow()),
 875:       "ToggleButton.shadow", new ColorUIResource(getPrimaryControlShadow()),
 876: 
 877:       "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
 878:       "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
 879:       "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
 880:       "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
 881:       "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
 882:       "Tree.font", new FontUIResource(new Font("Helvetica", Font.PLAIN, 12)),
 883:       "Tree.background", new ColorUIResource(Color.white),
 884:       "Tree.foreground", new ColorUIResource(new Color(204, 204, 255)),
 885:       "Tree.hash", new ColorUIResource(new Color(204, 204, 255)),
 886:       "Tree.leftChildIndent", new Integer(7),
 887:       "Tree.rightChildIndent", new Integer(13),
 888:       "Tree.rowHeight", new Integer(20),
 889:       "Tree.scrollsOnExpand", Boolean.TRUE,
 890:       "Tree.selectionBackground", new ColorUIResource(new Color(204, 204, 255)),
 891:       "Tree.nonSelectionBackground", new ColorUIResource(Color.white),
 892:       "Tree.selectionBorderColor", new ColorUIResource(new Color(102, 102, 153)),
 893:       "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
 894:       "Tree.nonSelectionBorder", new BorderUIResource.LineBorderUIResource(Color.white),
 895:       "Tree.selectionForeground", new ColorUIResource(Color.black),
 896:       "Tree.textBackground", new ColorUIResource(new Color(204, 204, 255)),
 897:       "Tree.textForeground", new ColorUIResource(Color.black),
 898:       "Tree.selectionForeground", new ColorUIResource(Color.black),
 899:       "PopupMenu.border", new MetalBorders.PopupMenuBorder()
 900:     };
 901:     defaults.putDefaults(myDefaults);
 902:   }
 903: 
 904:   /**
 905:    * Initializes the system color defaults.
 906:    *
 907:    * In particular this sets the following keys:
 908:    *
 909:    * <table>
 910:    * <tr>
 911:    * <th>Key</th><th>Value</th><th>Description</th>
 912:    * </tr><tr>
 913:    * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
 914:    * </tr>
 915:    * </table>
 916:    */
 917:   protected void initSystemColorDefaults(UIDefaults defaults)
 918:   {
 919:     super.initSystemColorDefaults(defaults);
 920:     Object[] uiDefaults;
 921:     uiDefaults = new Object[] {
 922:       "control", new ColorUIResource(getControl()),
 923:       "desktop", new ColorUIResource(getDesktopColor())
 924:     };
 925:     defaults.putDefaults(uiDefaults);
 926:   }
 927: 
 928: }