Source for javax.swing.plaf.metal.MetalLookAndFeel

   1: /* MetalLookAndFeel.java
   2:    Copyright (C) 2002, 2005, 2006, 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: 
  44: import javax.swing.LookAndFeel;
  45: import javax.swing.UIDefaults;
  46: import javax.swing.UIManager;
  47: import javax.swing.plaf.BorderUIResource;
  48: import javax.swing.plaf.ColorUIResource;
  49: import javax.swing.plaf.FontUIResource;
  50: import javax.swing.plaf.InsetsUIResource;
  51: import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
  52: import javax.swing.plaf.basic.BasicLookAndFeel;
  53: 
  54: 
  55: /**
  56:  * A custom look and feel that is designed to look similar across different
  57:  * operating systems.  To install this look and feel, add the following code 
  58:  * (or something similar) near the start of your application:</p>
  59:  * <pre>
  60:  * try
  61:  * {
  62:  * &nbsp;&nbsp;UIManager.setLookAndFeel(new MetalLookAndFeel());
  63:  * }
  64:  * catch (UnsupportedLookAndFeelException e)
  65:  * {
  66:  * &nbsp;&nbsp;e.printStackTrace();
  67:  * }</pre>
  68:  */
  69: public class MetalLookAndFeel extends BasicLookAndFeel
  70: {          
  71:   private static final long serialVersionUID = 6680646159193457980L;
  72:   
  73:   /** The current theme. */
  74:   private static MetalTheme theme;
  75:   
  76:   /** The look and feel defaults. */
  77:   private UIDefaults LAF_defaults;
  78: 
  79:   /**
  80:    * Creates a new instance of the Metal look and feel.
  81:    */
  82:   public MetalLookAndFeel()
  83:   {
  84:     createDefaultTheme();
  85:   }
  86: 
  87:   /**
  88:    * Sets the current theme to a new instance of {@link OceanTheme}.
  89:    */
  90:   protected void createDefaultTheme()
  91:   {
  92:     if (theme == null)
  93:       setCurrentTheme(new OceanTheme());
  94:   }
  95: 
  96:   /**
  97:    * Returns <code>false</code> to indicate that this look and feel does not
  98:    * attempt to emulate the look and feel of native applications on the host
  99:    * platform.
 100:    * 
 101:    * @return <code>false</code>.
 102:    */
 103:   public boolean isNativeLookAndFeel()
 104:   {
 105:     return false;
 106:   }
 107: 
 108:   /**
 109:    * Returns <code>true</code> to indicate that this look and feel is supported
 110:    * on all platforms.
 111:    * 
 112:    * @return <code>true</code>.
 113:    */
 114:   public boolean isSupportedLookAndFeel()
 115:   {
 116:     return true;
 117:   }
 118: 
 119:   /**
 120:    * Returns a string describing the look and feel.  In this case, the method
 121:    * returns "Metal look and feel".
 122:    * 
 123:    * @return A string describing the look and feel.
 124:    */
 125:   public String getDescription()
 126:   {
 127:     return "The Java(tm) Look and Feel";
 128:   }
 129: 
 130:   /**
 131:    * Returns the look and feel identifier.
 132:    * 
 133:    * @return "MetalLookAndFeel".
 134:    */
 135:   public String getID()
 136:   {
 137:     return "Metal";
 138:   }
 139: 
 140:   /**
 141:    * Returns the look and feel name.
 142:    * 
 143:    * @return "MetalLookAndFeel".
 144:    */
 145:   public String getName()
 146:   {
 147:     return "Metal";
 148:   }
 149: 
 150:   public UIDefaults getDefaults()
 151:   {
 152:     if (LAF_defaults == null)
 153:       {
 154:         LAF_defaults = super.getDefaults();
 155: 
 156:         // add custom theme entries to the table
 157:         if (theme != null)
 158:           theme.addCustomEntriesToTable(LAF_defaults);
 159:       }
 160:     
 161:     // Returns the default values for this look and feel. 
 162:     return LAF_defaults;
 163:   }
 164: 
 165:   /**
 166:    * Returns the accelerator foreground color from the installed theme.
 167:    * 
 168:    * @return The accelerator foreground color.
 169:    */
 170:   public static ColorUIResource getAcceleratorForeground()
 171:   {
 172:     if (theme != null)
 173:       return theme.getAcceleratorForeground();
 174:     return null;
 175:   }
 176: 
 177:   /**
 178:    * Returns the accelerator selected foreground color from the installed 
 179:    * theme.
 180:    * 
 181:    * @return The accelerator selected foreground color.
 182:    */
 183:   public static ColorUIResource getAcceleratorSelectedForeground()
 184:   {
 185:     if (theme != null)
 186:       return theme.getAcceleratorSelectedForeground();
 187:     return null;
 188:   }
 189: 
 190:   /**
 191:    * Returns the color black from the installed theme.
 192:    * 
 193:    * @return The color black.
 194:    */
 195:   public static ColorUIResource getBlack()
 196:   {
 197:     if (theme != null)
 198:       return theme.getBlack();
 199:     return null;
 200:   }
 201: 
 202:   /**
 203:    * Returns the control color from the installed theme.
 204:    * 
 205:    * @return The control color.
 206:    */
 207:   public static ColorUIResource getControl()
 208:   {
 209:     if (theme != null)
 210:       return theme.getControl();
 211:     return null;
 212:   }
 213: 
 214:   /**
 215:    * Returns the color used for dark shadows on controls, from the installed
 216:    * theme.
 217:    * 
 218:    * @return The color used for dark shadows on controls.
 219:    */
 220:   public static ColorUIResource getControlDarkShadow()
 221:   {
 222:     if (theme != null)
 223:       return theme.getControlDarkShadow();
 224:     return null;
 225:   }
 226: 
 227:   /**
 228:    * Returns the color used for disabled controls, from the installed theme.
 229:    * 
 230:    * @return The color used for disabled controls.
 231:    */
 232:   public static ColorUIResource getControlDisabled()
 233:   {
 234:     if (theme != null)
 235:       return theme.getControlDisabled();
 236:     return null;
 237:   }
 238: 
 239:   /**
 240:    * Returns the color used to draw highlights for controls, from the installed
 241:    * theme.
 242:    * 
 243:    * @return The color used to draw highlights for controls.
 244:    */
 245:   public static ColorUIResource getControlHighlight()
 246:   {
 247:     if (theme != null)
 248:       return theme.getControlHighlight();
 249:     return null;
 250:   }
 251: 
 252:   /**
 253:    * Returns the color used to display control info, from the installed 
 254:    * theme.
 255:    * 
 256:    * @return The color used to display control info.
 257:    */
 258:   public static ColorUIResource getControlInfo()
 259:   {
 260:     if (theme != null)
 261:       return theme.getControlInfo();
 262:     return null;
 263:   }
 264: 
 265:   /**
 266:    * Returns the color used to draw shadows for controls, from the installed
 267:    * theme.
 268:    * 
 269:    * @return The color used to draw shadows for controls.
 270:    */
 271:   public static ColorUIResource getControlShadow()
 272:   {
 273:     if (theme != null)
 274:       return theme.getControlShadow();
 275:     return null;
 276:   }
 277: 
 278:   /**
 279:    * Returns the color used for text on controls, from the installed theme.
 280:    * 
 281:    * @return The color used for text on controls.
 282:    */
 283:   public static ColorUIResource getControlTextColor()
 284:   {
 285:     if (theme != null)
 286:       return theme.getControlTextColor();
 287:     return null;
 288:   }
 289: 
 290:   /**
 291:    * Returns the font used for text on controls, from the installed theme.
 292:    * 
 293:    * @return The font used for text on controls.
 294:    */
 295:   public static FontUIResource getControlTextFont()
 296:   {
 297:     if (theme != null)
 298:       return theme.getControlTextFont();
 299:     return null;
 300:   }
 301: 
 302:   /**
 303:    * Returns the color used for the desktop background, from the installed 
 304:    * theme.
 305:    * 
 306:    * @return The color used for the desktop background.
 307:    */
 308:   public static ColorUIResource getDesktopColor()
 309:   {
 310:     if (theme != null)
 311:       return theme.getDesktopColor();
 312:     return null;
 313:   }
 314: 
 315:   /**
 316:    * Returns the color used to draw focus highlights, from the installed 
 317:    * theme.
 318:    * 
 319:    * @return The color used to draw focus highlights.
 320:    */
 321:   public static ColorUIResource getFocusColor()
 322:   {
 323:     if (theme != null)
 324:       return theme.getFocusColor();
 325:     return null;
 326:   }
 327: 
 328:   /**
 329:    * Returns the color used to draw highlighted text, from the installed
 330:    * theme.
 331:    * 
 332:    * @return The color used to draw highlighted text.
 333:    */
 334:   public static ColorUIResource getHighlightedTextColor()
 335:   {
 336:     if (theme != null)
 337:       return theme.getHighlightedTextColor();
 338:     return null;
 339:   }
 340: 
 341:   /**
 342:    * Returns the color used to draw text on inactive controls, from the
 343:    * installed theme.
 344:    * 
 345:    * @return The color used to draw text on inactive controls.
 346:    */
 347:   public static ColorUIResource getInactiveControlTextColor()
 348:   {
 349:     if (theme != null)
 350:       return theme.getInactiveControlTextColor();
 351:     return null;
 352:   }
 353: 
 354:   /**
 355:    * Returns the color used to draw inactive system text, from the installed
 356:    * theme.
 357:    * 
 358:    * @return The color used to draw inactive system text.
 359:    */
 360:   public static ColorUIResource getInactiveSystemTextColor()
 361:   {
 362:     if (theme != null)
 363:       return theme.getInactiveSystemTextColor();
 364:     return null;
 365:   }
 366: 
 367:   /**
 368:    * Returns the background color for menu items, from the installed theme.
 369:    * 
 370:    * @return The background color for menu items.
 371:    * 
 372:    * @see #getMenuSelectedBackground()
 373:    */
 374:   public static ColorUIResource getMenuBackground()
 375:   {
 376:     if (theme != null)
 377:       return theme.getMenuBackground();
 378:     return null;
 379:   }
 380: 
 381:   /**
 382:    * Returns the foreground color for disabled menu items, from the installed
 383:    * theme.
 384:    * 
 385:    * @return The foreground color for disabled menu items.
 386:    * 
 387:    * @see #getMenuForeground()
 388:    */
 389:   public static ColorUIResource getMenuDisabledForeground()
 390:   {
 391:     if (theme != null)
 392:       return theme.getMenuDisabledForeground();
 393:     return null;
 394:   }
 395: 
 396:   /**
 397:    * Returns the foreground color for menu items, from the installed theme.
 398:    * 
 399:    * @return The foreground color for menu items.
 400:    * 
 401:    * @see #getMenuDisabledForeground()
 402:    * @see #getMenuSelectedForeground()
 403:    */
 404:   public static ColorUIResource getMenuForeground()
 405:   {
 406:     if (theme != null)
 407:       return theme.getMenuForeground();
 408:     return null;
 409:   }
 410: 
 411:   /**
 412:    * Returns the background color for selected menu items, from the installed
 413:    * theme.
 414:    * 
 415:    * @return The background color for selected menu items.
 416:    * 
 417:    * @see #getMenuBackground()
 418:    */
 419:   public static ColorUIResource getMenuSelectedBackground()
 420:   {
 421:     if (theme != null)
 422:       return theme.getMenuSelectedBackground();
 423:     return null;
 424:   }
 425: 
 426:   /**
 427:    * Returns the foreground color for selected menu items, from the installed
 428:    * theme.
 429:    * 
 430:    * @return The foreground color for selected menu items.
 431:    * 
 432:    * @see #getMenuForeground()
 433:    */
 434:   public static ColorUIResource getMenuSelectedForeground()
 435:   {
 436:     if (theme != null)
 437:       return theme.getMenuSelectedForeground();
 438:     return null;
 439:   }
 440: 
 441:   /**
 442:    * Returns the font used for text in menus, from the installed theme.
 443:    * 
 444:    * @return The font used for text in menus.
 445:    */
 446:   public static FontUIResource getMenuTextFont()
 447:   {
 448:     if (theme != null)
 449:       return theme.getMenuTextFont();
 450:     return null;
 451:   }
 452: 
 453:   /**
 454:    * Returns the primary color for controls, from the installed theme.
 455:    * 
 456:    * @return The primary color for controls.
 457:    */
 458:   public static ColorUIResource getPrimaryControl()
 459:   {
 460:     if (theme != null)
 461:       return theme.getPrimaryControl();
 462:     return null;
 463:   }
 464: 
 465:   /**
 466:    * Returns the primary color for the dark shadow on controls, from the 
 467:    * installed theme.
 468:    * 
 469:    * @return The primary color for the dark shadow on controls.
 470:    */
 471:   public static ColorUIResource getPrimaryControlDarkShadow()
 472:   {
 473:     if (theme != null)
 474:       return theme.getPrimaryControlDarkShadow();
 475:     return null;
 476:   }
 477: 
 478:   /**
 479:    * Returns the primary color for the highlight on controls, from the 
 480:    * installed theme.
 481:    * 
 482:    * @return The primary color for the highlight on controls.
 483:    */
 484:   public static ColorUIResource getPrimaryControlHighlight()
 485:   {
 486:     if (theme != null)
 487:       return theme.getPrimaryControlHighlight();
 488:     return null;
 489:   }
 490: 
 491:   /**
 492:    * Returns the primary color for the information on controls, from the 
 493:    * installed theme.
 494:    * 
 495:    * @return The primary color for the information on controls.
 496:    */
 497:   public static ColorUIResource getPrimaryControlInfo()
 498:   {
 499:     if (theme != null)
 500:       return theme.getPrimaryControlInfo();
 501:     return null;
 502:   }
 503: 
 504:   /**
 505:    * Returns the primary color for the shadow on controls, from the installed
 506:    * theme.
 507:    * 
 508:    * @return The primary color for the shadow on controls.
 509:    */
 510:   public static ColorUIResource getPrimaryControlShadow()
 511:   {
 512:     if (theme != null)
 513:       return theme.getPrimaryControlShadow();
 514:     return null;
 515:   }
 516: 
 517:   /**
 518:    * Returns the background color for separators, from the installed theme.
 519:    * 
 520:    * @return The background color for separators.
 521:    */
 522:   public static ColorUIResource getSeparatorBackground()
 523:   {
 524:     if (theme != null)
 525:       return theme.getSeparatorBackground();
 526:     return null;
 527:   }
 528: 
 529:   /**
 530:    * Returns the foreground color for separators, from the installed theme.
 531:    * 
 532:    * @return The foreground color for separators.
 533:    */
 534:   public static ColorUIResource getSeparatorForeground()
 535:   {
 536:     if (theme != null)
 537:       return theme.getSeparatorForeground();
 538:     return null;
 539:   }
 540: 
 541:   /**
 542:    * Returns the font used for sub text, from the installed theme.
 543:    * 
 544:    * @return The font used for sub text.
 545:    */
 546:   public static FontUIResource getSubTextFont()
 547:   {
 548:     if (theme != null)
 549:       return theme.getSubTextFont();
 550:     return null;
 551:   }
 552: 
 553:   /**
 554:    * Returns the color used for system text, from the installed theme.
 555:    * 
 556:    * @return The color used for system text.
 557:    */
 558:   public static ColorUIResource getSystemTextColor()
 559:   {
 560:     if (theme != null)
 561:       return theme.getSystemTextColor();
 562:     return null;
 563:   }
 564: 
 565:   /**
 566:    * Returns the font used for system text, from the installed theme.
 567:    * 
 568:    * @return The font used for system text.
 569:    */
 570:   public static FontUIResource getSystemTextFont()
 571:   {
 572:     if (theme != null)
 573:       return theme.getSystemTextFont();
 574:     return null;
 575:   }
 576: 
 577:   /**
 578:    * Returns the color used to highlight text, from the installed theme.
 579:    * 
 580:    * @return The color used to highlight text.
 581:    */
 582:   public static ColorUIResource getTextHighlightColor()
 583:   {
 584:     if (theme != null)
 585:       return theme.getTextHighlightColor();
 586:     return null;
 587:   }
 588: 
 589:   /**
 590:    * Returns the color used to display user text, from the installed theme.
 591:    * 
 592:    * @return The color used to display user text.
 593:    */
 594:   public static ColorUIResource getUserTextColor()
 595:   {
 596:     if (theme != null)
 597:       return theme.getUserTextColor();
 598:     return null;
 599:   }
 600: 
 601:   /**
 602:    * Returns the font used for user text, obtained from the current theme.
 603:    * 
 604:    * @return The font used for user text.
 605:    */
 606:   public static FontUIResource getUserTextFont()
 607:   {
 608:     if (theme != null)
 609:       return theme.getUserTextFont();
 610:     return null;
 611:   }
 612: 
 613:   /**
 614:    * Returns the color used for white, from the installed theme.
 615:    * 
 616:    * @return The color used for white.
 617:    */
 618:   public static ColorUIResource getWhite()
 619:   {
 620:     if (theme != null)
 621:       return theme.getWhite();
 622:     return null;
 623:   }
 624: 
 625:   /**
 626:    * Returns the window background color, from the installed theme.
 627:    * 
 628:    * @return The window background color.
 629:    */
 630:   public static ColorUIResource getWindowBackground()
 631:   {
 632:     if (theme != null)
 633:       return theme.getWindowBackground();
 634:     return null;
 635:   }
 636: 
 637:   /**
 638:    * Returns the window title background color, from the installed theme.
 639:    * 
 640:    * @return The window title background color.
 641:    */
 642:   public static ColorUIResource getWindowTitleBackground()
 643:   {
 644:     if (theme != null)
 645:       return theme.getWindowTitleBackground();
 646:     return null;
 647:   }
 648: 
 649:   /**
 650:    * Returns the window title font from the current theme.
 651:    * 
 652:    * @return The window title font.
 653:    * 
 654:    * @see MetalTheme
 655:    */
 656:   public static FontUIResource getWindowTitleFont()
 657:   {
 658:     if (theme != null)
 659:       return theme.getWindowTitleFont();
 660:     return null;
 661:   }
 662: 
 663:   /**
 664:    * Returns the window title foreground color, from the installed theme.
 665:    * 
 666:    * @return The window title foreground color.
 667:    */
 668:   public static ColorUIResource getWindowTitleForeground()
 669:   {
 670:     if (theme != null)
 671:       return theme.getWindowTitleForeground();
 672:     return null;
 673:   }
 674: 
 675:   /**
 676:    * Returns the background color for an inactive window title, from the 
 677:    * installed theme.
 678:    * 
 679:    * @return The background color for an inactive window title.
 680:    */
 681:   public static ColorUIResource getWindowTitleInactiveBackground()
 682:   {
 683:     if (theme != null)
 684:       return theme.getWindowTitleInactiveBackground();
 685:     return null;
 686:   }
 687: 
 688:   /**
 689:    * Returns the foreground color for an inactive window title, from the 
 690:    * installed theme.
 691:    * 
 692:    * @return The foreground color for an inactive window title.
 693:    */
 694:   public static ColorUIResource getWindowTitleInactiveForeground()
 695:   {
 696:     if (theme != null)
 697:       return theme.getWindowTitleInactiveForeground();
 698:     return null;
 699:   }
 700: 
 701:   /**
 702:    * Sets the current theme for the look and feel.  Note that the theme must be 
 703:    * set <em>before</em> the look and feel is installed.  To change the theme 
 704:    * for an already running application that is using the 
 705:    * {@link MetalLookAndFeel}, first set the theme with this method, then 
 706:    * create a new instance of {@link MetalLookAndFeel} and install it in the 
 707:    * usual way (see {@link UIManager#setLookAndFeel(LookAndFeel)}).
 708:    * 
 709:    * @param theme  the theme (<code>null</code> not permitted).
 710:    * 
 711:    * @throws NullPointerException if <code>theme</code> is <code>null</code>.
 712:    * 
 713:    * @see #getCurrentTheme()
 714:    */
 715:   public static void setCurrentTheme(MetalTheme theme)
 716:   {
 717:     if (theme == null)
 718:       throw new NullPointerException("Null 'theme' not permitted.");
 719:     MetalLookAndFeel.theme = theme;
 720:   }
 721: 
 722:   /**
 723:    * Sets the ComponentUI classes for all Swing components to the Metal
 724:    * implementations.
 725:    *
 726:    * In particular this sets the following keys:
 727:    *
 728:    * <table>
 729:    * <tr>
 730:    * <th>Key</th><th>Value</th>
 731:    * </tr><tr>
 732:    * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
 733:    * </tr><tr>
 734:    * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
 735:    * </tr><tr>
 736:    * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
 737:    * </tr><tr>
 738:    * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
 739:    * </tr><tr>
 740:    * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
 741:    * </tr><tr>
 742:    * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
 743:    * </tr><tr>
 744:    * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
 745:    * </tr><tr>
 746:    * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
 747:    * </tr><tr>
 748:    * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
 749:    * </tr><tr>
 750:    * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
 751:    * </tr><tr>
 752:    * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
 753:    * </tr><tr>
 754:    * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
 755:    * </tr><tr>
 756:    * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
 757:    * </tr><tr>
 758:    * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
 759:    * </tr><tr>
 760:    * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
 761:    * </tr><tr>
 762:    * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
 763:    * </tr><tr>
 764:    * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
 765:    * </tr><tr>
 766:    * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
 767:    * </tr><tr>
 768:    * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
 769:    * </tr><tr>
 770:    * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
 771:    * </tr><tr>
 772:    * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
 773:    * </tr><tr>
 774:    * </table>
 775:    *
 776:    * @param defaults the UIDefaults where the class defaults are added
 777:    */
 778:   protected void initClassDefaults(UIDefaults defaults)
 779:   {
 780:     super.initClassDefaults(defaults);
 781: 
 782:     // Variables
 783:     Object[] uiDefaults;
 784:     // Initialize Class Defaults
 785:     uiDefaults = new Object[] {
 786:       "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
 787:       "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
 788:       "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
 789:       "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
 790:       "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
 791:       "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
 792:       "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
 793:       "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
 794:       "PopupMenuSeparatorUI",
 795:       "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
 796:       "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
 797:       "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
 798:       "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
 799:       "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
 800:       "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
 801:       "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
 802:       "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
 803:       "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
 804:       "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
 805:       "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
 806:       "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
 807:       "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
 808:       "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
 809:       "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
 810:     };
 811:     // Add Class Defaults to UI Defaults table
 812:     defaults.putDefaults(uiDefaults);
 813:   }
 814: 
 815:   /**
 816:    * Initializes the component defaults for the Metal Look &amp; Feel.
 817:    *
 818:    * In particular this sets the following keys (the colors are given
 819:    * as RGB hex values):
 820:    *
 821:    * <table>
 822:    * <tr>
 823:    * <th>Key</th><th>Value</th>
 824:    * </tr><tr>
 825:    * <td>Button.background</td><td>0xcccccc</td>
 826:    * </tr><tr>
 827:    * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
 828:    * </tr><tr>
 829:    * <td>Button.font</td><td>{@link #getControlTextFont}</td>
 830:    * </tr><tr>
 831:    * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
 832:    * </td>
 833:    * </tr><tr>
 834:    * <td>CheckBox.background</td><td>0xcccccc</td>
 835:    * </tr><tr>
 836:    * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
 837:    * </tr><tr>
 838:    * <td>ToolBar.background</td><td>0xcccccc</td>
 839:    * </tr><tr>
 840:    * <td>Panel.background</td><td>0xcccccc</td>
 841:    * </tr><tr>
 842:    * <td>Slider.background</td><td>0xcccccc</td>
 843:    * </tr><tr>
 844:    * <td>OptionPane.background</td><td>0xcccccc</td>
 845:    * </tr><tr>
 846:    * <td>ProgressBar.background</td><td>0xcccccc</td>
 847:    * </tr><tr>
 848:    * <td>TabbedPane.background</td><td>0xcccccc</td>
 849:    * </tr><tr>
 850:    * <td>Label.background</td><td>0xcccccc</td>
 851:    * </tr><tr>
 852:    * <td>Label.font</td><td>{@link #getControlTextFont}</td>
 853:    * </tr><tr>
 854:    * <td>Menu.background</td><td>0xcccccc</td>
 855:    * </tr><tr>
 856:    * <td>MenuBar.background</td><td>0xcccccc</td>
 857:    * </tr><tr>
 858:    * <td>MenuItem.background</td><td>0xcccccc</td>
 859:    * </tr><tr>
 860:    * <td>ScrollBar.background</td><td>0xcccccc</td>
 861:    * </tr><tr>
 862:    * <td>PopupMenu.border</td>
 863:    * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
 864:    * </tr><tr>
 865:    * </table>
 866:    *
 867:    * @param defaults the UIDefaults instance to which the values are added
 868:    */
 869:   protected void initComponentDefaults(UIDefaults defaults)
 870:   {
 871:     super.initComponentDefaults(defaults);
 872:     Object[] myDefaults = new Object[] {
 873:       "Button.background", getControl(),
 874:       "Button.border", MetalBorders.getButtonBorder(),
 875:       "Button.darkShadow", getControlDarkShadow(),
 876:       "Button.disabledText", getInactiveControlTextColor(),
 877:       "Button.focus", getFocusColor(),
 878:       "Button.font", getControlTextFont(),
 879:       "Button.foreground", getControlTextColor(),
 880:       "Button.highlight", getControlHighlight(),
 881:       "Button.light", getControlHighlight(),
 882:       "Button.margin", new InsetsUIResource(2, 14, 2, 14),
 883:       "Button.select", getControlShadow(),
 884:       "Button.shadow", getControlShadow(),
 885: 
 886:       "CheckBox.background", getControl(),
 887:       "CheckBox.border", MetalBorders.getButtonBorder(),
 888:       "CheckBox.disabledText", getInactiveControlTextColor(),
 889:       "CheckBox.focus", getFocusColor(),
 890:       "CheckBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
 891:       "CheckBox.foreground", getControlTextColor(),
 892:       "CheckBox.icon",
 893:       new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
 894:       "CheckBox.checkIcon",
 895:       new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
 896:       "Checkbox.select", getControlShadow(),
 897: 
 898:       "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
 899:       "CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
 900:       "CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
 901:       "CheckBoxMenuItem.background", getMenuBackground(),
 902:       "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
 903:       "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
 904:       "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
 905:       "CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
 906:       "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.BOLD, 12),
 907:       "CheckBoxMenuItem.foreground", getMenuForeground(),
 908:       "CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
 909:       "CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
 910: 
 911:       "ColorChooser.background", getControl(),
 912:       "ColorChooser.foreground", getControlTextColor(),
 913:       "ColorChooser.rgbBlueMnemonic", new Integer(0),
 914:       "ColorChooser.rgbGreenMnemonic", new Integer(0),
 915:       "ColorChooser.rgbRedMnemonic", new Integer(0),
 916:       "ColorChooser.swatchesDefaultRecentColor", getControl(),
 917: 
 918:       "ComboBox.background", getControl(),
 919:       "ComboBox.buttonBackground", getControl(),
 920:       "ComboBox.buttonDarkShadow", getControlDarkShadow(),
 921:       "ComboBox.buttonHighlight", getControlHighlight(),
 922:       "ComboBox.buttonShadow", getControlShadow(),
 923:       "ComboBox.disabledBackground", getControl(),
 924:       "ComboBox.disabledForeground", getInactiveSystemTextColor(),
 925:       "ComboBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
 926:       "ComboBox.foreground", getControlTextColor(),
 927:       "ComboBox.selectionBackground", getPrimaryControlShadow(),
 928:       "ComboBox.selectionForeground", getControlTextColor(),
 929: 
 930:       "Desktop.background", getDesktopColor(),
 931: 
 932:       "DesktopIcon.background", getControl(),
 933:       "DesktopIcon.foreground", getControlTextColor(),
 934:       "DesktopIcon.width", new Integer(160),
 935:       "DesktopIcon.border", MetalBorders.getDesktopIconBorder(),
 936: 
 937:       "EditorPane.background", getWindowBackground(),
 938:       "EditorPane.caretForeground", getUserTextColor(),
 939:       "EditorPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
 940:       "EditorPane.foreground",  getUserTextColor(),
 941:       "EditorPane.inactiveForeground",  getInactiveSystemTextColor(),
 942:       "EditorPane.selectionBackground", getTextHighlightColor(),
 943:       "EditorPane.selectionForeground", getHighlightedTextColor(),
 944:       
 945:       "FormattedTextField.background", getWindowBackground(),
 946:       "FormattedTextField.border",
 947:       new BorderUIResource(MetalBorders.getTextFieldBorder()),
 948:       "FormattedTextField.caretForeground", getUserTextColor(),
 949:       "FormattedTextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
 950:       "FormattedTextField.foreground",  getUserTextColor(),
 951:       "FormattedTextField.inactiveBackground",  getControl(),
 952:       "FormattedTextField.inactiveForeground",  getInactiveSystemTextColor(),
 953:       "FormattedTextField.selectionBackground", getTextHighlightColor(),
 954:       "FormattedTextField.selectionForeground", getHighlightedTextColor(),
 955: 
 956:       "FileChooser.upFolderIcon", 
 957:           MetalIconFactory.getFileChooserUpFolderIcon(),
 958:       "FileChooser.listViewIcon", 
 959:           MetalIconFactory.getFileChooserListViewIcon(),
 960:       "FileChooser.newFolderIcon", 
 961:           MetalIconFactory.getFileChooserNewFolderIcon(),
 962:       "FileChooser.homeFolderIcon", 
 963:           MetalIconFactory.getFileChooserHomeFolderIcon(),
 964:       "FileChooser.detailsViewIcon", 
 965:           MetalIconFactory.getFileChooserDetailViewIcon(),
 966:       "FileChooser.fileNameLabelMnemonic", new Integer(78),
 967:       "FileChooser.filesOfTypeLabelMnemonic", new Integer(84),
 968:       "FileChooser.lookInLabelMnemonic", new Integer(73),
 969:       "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
 970:       "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
 971:       "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
 972:       "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
 973:       "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
 974: 
 975:       "InternalFrame.activeTitleBackground", getWindowTitleBackground(),
 976:       "InternalFrame.activeTitleForeground", getWindowTitleForeground(),
 977:       "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
 978:       "InternalFrame.borderColor", getControl(),
 979:       "InternalFrame.borderDarkShadow", getControlDarkShadow(),
 980:       "InternalFrame.borderHighlight", getControlHighlight(),
 981:       "InternalFrame.borderLight", getControlHighlight(),
 982:       "InternalFrame.borderShadow", getControlShadow(),
 983:       "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
 984:       "InternalFrame.closeIcon", 
 985:         MetalIconFactory.getInternalFrameCloseIcon(16),
 986:       "InternalFrame.closeSound", "sounds/FrameClose.wav",
 987:       "InternalFrame.inactiveTitleBackground", getWindowTitleInactiveBackground(),
 988:       "InternalFrame.inactiveTitleForeground", getWindowTitleInactiveForeground(),
 989:       "InternalFrame.maximizeIcon", 
 990:         MetalIconFactory.getInternalFrameMaximizeIcon(16),
 991:       "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
 992:       "InternalFrame.iconifyIcon", 
 993:         MetalIconFactory.getInternalFrameMinimizeIcon(16),
 994:       "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
 995:       "InternalFrame.paletteBorder", new MetalBorders.PaletteBorder(),
 996:       "InternalFrame.paletteCloseIcon", new MetalIconFactory.PaletteCloseIcon(),
 997:       "InternalFrame.paletteTitleHeight", new Integer(11),
 998:       "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
 999:       "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
1000: 
1001:       "Label.background", getControl(),
1002:       "Label.disabledForeground", getInactiveSystemTextColor(),
1003:       "Label.disabledShadow", getControlShadow(),
1004:       "Label.font", getControlTextFont(),
1005:       "Label.foreground", getSystemTextColor(),
1006: 
1007:       "List.font", getControlTextFont(),
1008:       "List.background", getWindowBackground(),
1009:       "List.foreground", getUserTextColor(),
1010:       "List.selectionBackground", getTextHighlightColor(),
1011:       "List.selectionForeground", getHighlightedTextColor(),
1012:       "List.focusCellHighlightBorder", 
1013:         new LineBorderUIResource(MetalLookAndFeel.getFocusColor()),
1014: 
1015:       "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1016:       "Menu.acceleratorForeground", getAcceleratorForeground(),
1017:       "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1018:       "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
1019:       "Menu.background", getMenuBackground(),
1020:       "Menu.border", new MetalBorders.MenuItemBorder(),
1021:       "Menu.borderPainted", Boolean.TRUE,
1022:       "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
1023:       "Menu.disabledForeground", getMenuDisabledForeground(),
1024:       "Menu.font", getControlTextFont(),
1025:       "Menu.foreground", getMenuForeground(),
1026:       "Menu.selectionBackground", getMenuSelectedBackground(),
1027:       "Menu.selectionForeground", getMenuSelectedForeground(),
1028:       "Menu.submenuPopupOffsetX", new Integer(-4),
1029:       "Menu.submenuPopupOffsetY", new Integer(-3),
1030: 
1031:       "MenuBar.background", getMenuBackground(),
1032:       "MenuBar.border", new MetalBorders.MenuBarBorder(),
1033:       "MenuBar.font", getControlTextFont(),
1034:       "MenuBar.foreground", getMenuForeground(),
1035:       "MenuBar.highlight", getControlHighlight(),
1036:       "MenuBar.shadow", getControlShadow(),
1037: 
1038:       "MenuItem.acceleratorDelimiter", "-",
1039:       "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1040:       "MenuItem.acceleratorForeground", getAcceleratorForeground(),
1041:       "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1042:       "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
1043:       "MenuItem.background", getMenuBackground(),
1044:       "MenuItem.border", new MetalBorders.MenuItemBorder(),
1045:       "MenuItem.borderPainted", Boolean.TRUE,
1046:       "MenuItem.disabledForeground", getMenuDisabledForeground(),
1047:       "MenuItem.font", getControlTextFont(),
1048:       "MenuItem.foreground", getMenuForeground(),
1049:       "MenuItem.selectionBackground", getMenuSelectedBackground(),
1050:       "MenuItem.selectionForeground", getMenuSelectedForeground(),
1051: 
1052:       "OptionPane.background", getControl(),
1053:       "OptionPane.errorSound", "sounds/OptionPaneError.wav",
1054:       "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1055:       "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1056:       "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
1057:       "OptionPane.errorDialog.border.background", new ColorUIResource(153, 51, 51), 
1058:       "OptionPane.errorDialog.titlePane.background", new ColorUIResource(255, 153, 153),
1059:       "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(51, 0, 0),
1060:       "OptionPane.errorDialog.titlePane.shadow", new ColorUIResource(204, 102, 102),
1061:       "OptionPane.foreground", getControlTextColor(),
1062:       "OptionPane.messageForeground", getControlTextColor(),
1063:       "OptionPane.questionDialog.border.background", new ColorUIResource(51, 102, 51),
1064:       "OptionPane.questionDialog.titlePane.background", new ColorUIResource(153, 204, 153),
1065:       "OptionPane.questionDialog.titlePane.foreground", new ColorUIResource(0, 51, 0),
1066:       "OptionPane.questionDialog.titlePane.shadow", new ColorUIResource(102, 153, 102),
1067:       "OptionPane.warningDialog.border.background", new ColorUIResource(153, 102, 51),
1068:       "OptionPane.warningDialog.titlePane.background", new ColorUIResource(255, 204, 153),
1069:       "OptionPane.warningDialog.titlePane.foreground", new ColorUIResource(102, 51, 0),
1070:       "OptionPane.warningDialog.titlePane.shadow", new ColorUIResource(204, 153, 102),
1071: 
1072:       "Panel.background", getControl(),
1073:       "Panel.foreground", getUserTextColor(),
1074: 
1075:       "PasswordField.background", getWindowBackground(),
1076:       "PasswordField.border",
1077:       new BorderUIResource(MetalBorders.getTextFieldBorder()),
1078:       "PasswordField.caretForeground", getUserTextColor(),
1079:       "PasswordField.foreground", getUserTextColor(),
1080:       "PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1081:       "PasswordField.inactiveBackground", getControl(),
1082:       "PasswordField.inactiveForeground", getInactiveSystemTextColor(),
1083:       "PasswordField.selectionBackground", getTextHighlightColor(),
1084:       "PasswordField.selectionForeground", getHighlightedTextColor(),
1085: 
1086:       "PopupMenu.background", getMenuBackground(),
1087:       "PopupMenu.border", new MetalBorders.PopupMenuBorder(),
1088:       "PopupMenu.font", new FontUIResource("Dialog", Font.BOLD, 12),
1089:       "PopupMenu.foreground", getMenuForeground(),
1090:       "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
1091: 
1092:       "ProgressBar.background", getControl(),
1093:       "ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1094:       "ProgressBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
1095:       "ProgressBar.foreground", getPrimaryControlShadow(),
1096:       "ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
1097:       "ProgressBar.selectionForeground", getControl(),
1098: 
1099:       "RadioButton.background", getControl(),
1100:       "RadioButton.darkShadow", getControlDarkShadow(),
1101:       "RadioButton.disabledText", getInactiveControlTextColor(),
1102:       "RadioButton.icon",
1103:       new UIDefaults.LazyValue()
1104:       {
1105:         public Object createValue(UIDefaults def)
1106:           {
1107:             return MetalIconFactory.getRadioButtonIcon();
1108:           }
1109:       },
1110:       "RadioButton.focus", MetalLookAndFeel.getFocusColor(),
1111:       "RadioButton.font", MetalLookAndFeel.getControlTextFont(),
1112:       "RadioButton.foreground", getControlTextColor(),
1113:       "RadioButton.highlight", getControlHighlight(),
1114:       "RadioButton.light", getControlHighlight(),
1115:       "RadioButton.select", getControlShadow(),
1116:       "RadioButton.shadow", getControlShadow(),
1117: 
1118:       "RadioButtonMenuItem.acceleratorFont", new Font("Dialog", Font.PLAIN, 10),
1119:       "RadioButtonMenuItem.acceleratorForeground", getAcceleratorForeground(),
1120:       "RadioButtonMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1121:       "RadioButtonMenuItem.background", getMenuBackground(),
1122:       "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
1123:       "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
1124:       "RadioButtonMenuItem.checkIcon", 
1125:         MetalIconFactory.getRadioButtonMenuItemIcon(),
1126:       "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1127:       "RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
1128:       "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
1129:       "RadioButtonMenuItem.foreground", getMenuForeground(),
1130:       "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
1131:       "RadioButtonMenuItem.selectionBackground", 
1132:         MetalLookAndFeel.getMenuSelectedBackground(),
1133:       "RadioButtonMenuItem.selectionForeground", 
1134:         MetalLookAndFeel.getMenuSelectedForeground(),
1135: 
1136:       "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
1137:       "ScrollBar.background", getControl(),
1138:       "ScrollBar.darkShadow", getControlDarkShadow(),
1139:       "ScrollBar.foreground", getControl(),
1140:       "ScrollBar.highlight", getControlHighlight(),
1141:       "ScrollBar.shadow", getControlShadow(),
1142:       "ScrollBar.thumb", getPrimaryControlShadow(),
1143:       "ScrollBar.thumbDarkShadow", getControlDarkShadow(),
1144:       "ScrollBar.thumbHighlight", getPrimaryControl(),
1145:       "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
1146:       "ScrollBar.track", getControl(),
1147:       "ScrollBar.trackHighlight", getControlDarkShadow(),
1148:       "ScrollBar.width", new Integer(17),
1149: 
1150:       "ScrollPane.background", getControl(),
1151:       "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
1152:       "ScrollPane.foreground", getControlTextColor(),
1153: 
1154:       "Separator.background", getSeparatorBackground(),
1155:       "Separator.foreground", getSeparatorForeground(),
1156:       "Separator.highlight", getControlHighlight(),
1157:       "Separator.shadow", getControlShadow(),
1158: 
1159:       "Slider.background", getControl(),
1160:       "Slider.focus", getFocusColor(),
1161:       "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
1162:       "Slider.foreground", getPrimaryControlShadow(),
1163:       "Slider.highlight", getControlHighlight(),
1164:       "Slider.horizontalThumbIcon", 
1165:       MetalIconFactory.getHorizontalSliderThumbIcon(),
1166:       "Slider.majorTickLength", new Integer(6),
1167:       "Slider.shadow", getControlShadow(),
1168:       "Slider.trackWidth", new Integer(7),
1169:       "Slider.verticalThumbIcon", 
1170:       MetalIconFactory.getVerticalSliderThumbIcon(),
1171: 
1172:       "Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
1173:       "Spinner.background", getControl(),
1174:       "Spinner.border", MetalBorders.getTextFieldBorder(),
1175:       "Spinner.font", new FontUIResource("Dialog", Font.BOLD, 12),
1176:       "Spinner.foreground", getControl(),
1177: 
1178:       "SplitPane.background", getControl(),
1179:       "SplitPane.darkShadow", getControlDarkShadow(),
1180:       "SplitPane.dividerFocusColor", getPrimaryControl(),
1181:       "SplitPane.dividerSize", new Integer(10),
1182:       "SplitPane.highlight", getControlHighlight(),
1183:       "SplitPane.shadow", getControlShadow(),
1184: 
1185:       "SplitPaneDivider.draggingColor", Color.DARK_GRAY,
1186: 
1187:       "TabbedPane.background", getControlShadow(),
1188:       "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
1189:       "TabbedPane.contentOpaque", Boolean.TRUE,
1190:       "TabbedPane.darkShadow", getControlDarkShadow(),
1191:       "TabbedPane.focus", getPrimaryControlDarkShadow(),
1192:       "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
1193:       "TabbedPane.foreground", getControlTextColor(),
1194:       "TabbedPane.highlight", getControlHighlight(),
1195:       "TabbedPane.light", getControl(),
1196:       "TabbedPane.selected", getControl(), // overridden in OceanTheme
1197:       "TabbedPane.selectHighlight", getControlHighlight(),
1198:       "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
1199:       "TabbedPane.shadow", getControlShadow(),
1200:       "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme
1201:       "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito
1202:       "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
1203:       
1204:       // new properties in OceanTheme:
1205:       // TabbedPane.contentAreaColor
1206:       // TabbedPane.unselectedBackground
1207:       
1208:       "Table.background", getWindowBackground(),
1209:       "Table.focusCellBackground", getWindowBackground(),
1210:       "Table.focusCellForeground", getControlTextColor(),
1211:       "Table.foreground", getControlTextColor(),
1212:       "Table.focusCellHighlightBorder",
1213:       new BorderUIResource.LineBorderUIResource(getFocusColor()),
1214:       "Table.focusCellBackground", getWindowBackground(),
1215:       "Table.gridColor", getControlDarkShadow(),
1216:       "Table.selectionBackground", new ColorUIResource(204, 204, 255),
1217:       "Table.selectionForeground", new ColorUIResource(0, 0, 0),
1218: 
1219:       "TableHeader.background", getControl(),
1220:       "TableHeader.cellBorder", new MetalBorders.TableHeaderBorder(),
1221:       "TableHeader.foreground", getControlTextColor(),
1222: 
1223:       "TextArea.background", getWindowBackground(),
1224:       "TextArea.caretForeground", getUserTextColor(),
1225:       "TextArea.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1226:       "TextArea.foreground", getUserTextColor(),
1227:       "TextArea.inactiveForeground", getInactiveSystemTextColor(),
1228:       "TextArea.selectionBackground", getTextHighlightColor(),
1229:       "TextArea.selectionForeground", getHighlightedTextColor(),
1230: 
1231:       "TextField.background", getWindowBackground(),
1232:       "TextField.border",
1233:       new BorderUIResource(MetalBorders.getTextFieldBorder()),
1234:       "TextField.caretForeground", getUserTextColor(),
1235:       "TextField.darkShadow", getControlDarkShadow(),
1236:       "TextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1237:       "TextField.foreground", getUserTextColor(),
1238:       "TextField.highlight", getControlHighlight(),
1239:       "TextField.inactiveBackground", getControl(),
1240:       "TextField.inactiveForeground", getInactiveSystemTextColor(),
1241:       "TextField.light", getControlHighlight(),
1242:       "TextField.selectionBackground", getTextHighlightColor(),
1243:       "TextField.selectionForeground", getHighlightedTextColor(),
1244:       "TextField.shadow", getControlShadow(),
1245:      
1246:       "TextPane.background", getWindowBackground(),
1247:       "TextPane.caretForeground", getUserTextColor(),
1248:       "TextPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1249:       "TextPane.foreground", getUserTextColor(),
1250:       "TextPane.inactiveForeground", getInactiveSystemTextColor(),
1251:       "TextPane.selectionBackground", getTextHighlightColor(),
1252:       "TextPane.selectionForeground", getHighlightedTextColor(),
1253: 
1254:       "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
1255:       "TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12),
1256:       "TitledBorder.titleColor", getSystemTextColor(),
1257: 
1258:       "ToggleButton.background", getControl(),
1259:       "ToggleButton.border", MetalBorders.getToggleButtonBorder(),
1260:       "ToggleButton.darkShadow", getControlDarkShadow(),
1261:       "ToggleButton.disabledText", getInactiveControlTextColor(),
1262:       "ToggleButton.focus", getFocusColor(),
1263:       "ToggleButton.font", getControlTextFont(),
1264:       "ToggleButton.foreground", getControlTextColor(),
1265:       "ToggleButton.highlight", getControlHighlight(),
1266:       "ToggleButton.light", getControlHighlight(),
1267:       "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
1268:       "ToggleButton.select", getControlShadow(),
1269:       "ToggleButton.shadow", getControlShadow(),
1270: 
1271:       "ToolBar.background", getMenuBackground(),
1272:       "ToolBar.darkShadow", getControlDarkShadow(),
1273:       "ToolBar.dockingBackground", getMenuBackground(),
1274:       "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
1275:       "ToolBar.floatingBackground", getMenuBackground(),
1276:       "ToolBar.floatingForeground", getPrimaryControl(),
1277:       "ToolBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
1278:       "ToolBar.foreground", getMenuForeground(),
1279:       "ToolBar.highlight", getControlHighlight(),
1280:       "ToolBar.light", getControlHighlight(),
1281:       "ToolBar.shadow", getControlShadow(),
1282:       "ToolBar.border", new MetalBorders.ToolBarBorder(),
1283:       "ToolBar.rolloverBorder", MetalBorders.getToolbarButtonBorder(),
1284:       "ToolBar.nonrolloverBorder", MetalBorders.getToolbarButtonBorder(),
1285: 
1286:       "ToolTip.background", getPrimaryControl(),
1287:       "ToolTip.backgroundInactive", getControl(),
1288:       "ToolTip.border", new BorderUIResource.LineBorderUIResource(getPrimaryControlDarkShadow(), 1),
1289:       "ToolTip.borderInactive", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1290:       "ToolTip.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1291:       "ToolTip.foreground", getPrimaryControlInfo(),
1292:       "ToolTip.foregroundInactive", getControlDarkShadow(),
1293:       "ToolTip.hideAccelerator", Boolean.FALSE,
1294: 
1295:       "Tree.background", getWindowBackground(),
1296:       "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
1297:       "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
1298:       "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
1299:       "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1300:       "Tree.foreground", getUserTextColor(),
1301:       "Tree.hash", getPrimaryControl(),
1302:       "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
1303:       "Tree.leftChildIndent", new Integer(7),
1304:       "Tree.line", getPrimaryControl(),
1305:       "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
1306:       "Tree.rightChildIndent", new Integer(13),
1307:       "Tree.rowHeight", new Integer(0),
1308:       "Tree.scrollsOnExpand", Boolean.TRUE,
1309:       "Tree.selectionBackground", getTextHighlightColor(),
1310:       "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
1311:       "Tree.selectionBorderColor", getFocusColor(),
1312:       "Tree.selectionForeground", getHighlightedTextColor(),
1313:       "Tree.textBackground", getWindowBackground(),
1314:       "Tree.textForeground", getUserTextColor(),
1315: 
1316:       "Viewport.background", getControl(),
1317:       "Viewport.foreground", getUserTextColor()
1318:     };
1319:     defaults.putDefaults(myDefaults);
1320:   }
1321: 
1322:   /**
1323:    * Initializes the system color defaults.
1324:    *
1325:    * In particular this sets the following keys:
1326:    *
1327:    * <table>
1328:    * <tr>
1329:    * <th>Key</th><th>Value</th><th>Description</th>
1330:    * </tr><tr>
1331:    * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
1332:    * </tr>
1333:    * </table>
1334:    */
1335:   protected void initSystemColorDefaults(UIDefaults defaults)
1336:   {
1337:     super.initSystemColorDefaults(defaults);
1338:     Object[] uiDefaults;
1339:     uiDefaults = new Object[] {
1340:       "control", new ColorUIResource(getControl()),
1341:       "desktop", new ColorUIResource(getDesktopColor())
1342:     };
1343:     defaults.putDefaults(uiDefaults);
1344:   }
1345: 
1346:   /**
1347:    * Returns the current theme for the Metal look and feel.  The default is
1348:    * an instance of {@link OceanTheme}.
1349:    *
1350:    * @return The current theme (never <code>null</code>).
1351:    * 
1352:    * @see #setCurrentTheme(MetalTheme)
1353:    */
1354:   public static MetalTheme getCurrentTheme()
1355:   {
1356:     if (theme == null)
1357:       theme = new OceanTheme();
1358:     return theme;
1359:   }
1360: 
1361:   /**
1362:    * Returns <code>true</code> because the Metal look
1363:    * and feel supports window decorations for toplevel
1364:    * containers.
1365:    *
1366:    * @return <code>true</code>
1367:    */
1368:   public boolean getSupportsWindowDecorations()
1369:   {
1370:     return true;
1371:   }
1372: }