jdk/make/tools/src/build/tools/automulti/TestALFLookAndFeel.java
changeset 1367 11d2418bf7c1
parent 1366 62c548002ecb
parent 1353 b91d80edba0f
child 1368 a2879b2837f5
equal deleted inserted replaced
1366:62c548002ecb 1367:11d2418bf7c1
     1 /*
       
     2  * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 //package com.myco.myalaf;  //search for myalaf for other refs to package name
       
    26 
       
    27 
       
    28 package build.tools.automulti;
       
    29 
       
    30 import java.util.Vector;
       
    31 import java.lang.reflect.Method;
       
    32 import javax.swing.*;
       
    33 import javax.swing.plaf.*;
       
    34 
       
    35 /**
       
    36  * <p>An auxiliary look and feel used for testing the Multiplexing
       
    37  * look and feel.
       
    38  * <p>
       
    39  *
       
    40  * @see UIManager#addAuxiliaryLookAndFeel
       
    41  * @see javax.swing.plaf.multi
       
    42  *
       
    43  * @author Kathy Walrath
       
    44  * @author Will Walker
       
    45  */
       
    46 public class TestALFLookAndFeel extends LookAndFeel {
       
    47 
       
    48 //////////////////////////////
       
    49 // LookAndFeel methods
       
    50 //////////////////////////////
       
    51 
       
    52     /**
       
    53      * Returns a string, suitable for use in menus,
       
    54      * that identifies this look and feel.
       
    55      *
       
    56      * @return a string such as "Test Auxiliary Look and Feel"
       
    57      */
       
    58     public String getName() {
       
    59         return "Test Auxiliary Look and Feel";
       
    60     }
       
    61 
       
    62     /**
       
    63      * Returns a string, suitable for use by applications/services,
       
    64      * that identifies this look and feel.
       
    65      *
       
    66      * @return "TestALF"
       
    67      */
       
    68     public String getID() {
       
    69         return "TestALF";
       
    70     }
       
    71 
       
    72     /**
       
    73      * Returns a one-line description of this look and feel.
       
    74      *
       
    75      * @return a descriptive string such as "Allows multiple UI instances per component instance"
       
    76      */
       
    77     public String getDescription() {
       
    78         return "Allows multiple UI instances per component instance";
       
    79     }
       
    80 
       
    81     /**
       
    82      * Returns <code>false</code>;
       
    83      * this look and feel is not native to any platform.
       
    84      *
       
    85      * @return <code>false</code>
       
    86      */
       
    87     public boolean isNativeLookAndFeel() {
       
    88         return false;
       
    89     }
       
    90 
       
    91     /**
       
    92      * Returns <code>true</code>;
       
    93      * every platform permits this look and feel.
       
    94      *
       
    95      * @return <code>true</code>
       
    96      */
       
    97     public boolean isSupportedLookAndFeel() {
       
    98         return true;
       
    99     }
       
   100 
       
   101     /**
       
   102      * Creates, initializes, and returns
       
   103      * the look and feel specific defaults.
       
   104      * For this look and feel,
       
   105      * the defaults consist solely of
       
   106      * mappings of UI class IDs
       
   107      * (such as "ButtonUI")
       
   108      * to <code>ComponentUI</code> class names
       
   109      * (such as "com.myco.myalaf.MultiButtonUI").
       
   110      *
       
   111      * @return an initialized <code>UIDefaults</code> object
       
   112      * @see javax.swing.JComponent#getUIClassID
       
   113      */
       
   114     public UIDefaults getDefaults() {
       
   115         System.out.println("In the TestALFLookAndFeel getDefaults method.");
       
   116         UIDefaults table = new TestALFUIDefaults();
       
   117         //String prefix = "com.myco.myalaf.TestALF";
       
   118         String prefix = "TestALF";
       
   119         Object[] uiDefaults = {
       
   120                    "ButtonUI", prefix + "ButtonUI",
       
   121          "CheckBoxMenuItemUI", prefix + "MenuItemUI",
       
   122                  "CheckBoxUI", prefix + "ButtonUI",
       
   123              "ColorChooserUI", prefix + "ColorChooserUI",
       
   124                  "ComboBoxUI", prefix + "ComboBoxUI",
       
   125               "DesktopIconUI", prefix + "DesktopIconUI",
       
   126               "DesktopPaneUI", prefix + "DesktopPaneUI",
       
   127                "EditorPaneUI", prefix + "TextUI",
       
   128               "FileChooserUI", prefix + "FileChooserUI",
       
   129        "FormattedTextFieldUI", prefix + "TextUI",
       
   130             "InternalFrameUI", prefix + "InternalFrameUI",
       
   131                     "LabelUI", prefix + "LabelUI",
       
   132                      "ListUI", prefix + "ListUI",
       
   133                   "MenuBarUI", prefix + "MenuBarUI",
       
   134                  "MenuItemUI", prefix + "MenuItemUI",
       
   135                      "MenuUI", prefix + "MenuItemUI",
       
   136                "OptionPaneUI", prefix + "OptionPaneUI",
       
   137                     "PanelUI", prefix + "PanelUI",
       
   138             "PasswordFieldUI", prefix + "TextUI",
       
   139        "PopupMenuSeparatorUI", prefix + "SeparatorUI",
       
   140                 "PopupMenuUI", prefix + "PopupMenuUI",
       
   141               "ProgressBarUI", prefix + "ProgressBarUI",
       
   142       "RadioButtonMenuItemUI", prefix + "MenuItemUI",
       
   143               "RadioButtonUI", prefix + "ButtonUI",
       
   144                  "RootPaneUI", prefix + "RootPaneUI",
       
   145                 "ScrollBarUI", prefix + "ScrollBarUI",
       
   146                "ScrollPaneUI", prefix + "ScrollPaneUI",
       
   147                 "SeparatorUI", prefix + "SeparatorUI",
       
   148                    "SliderUI", prefix + "SliderUI",
       
   149                   "SpinnerUI", prefix + "SpinnerUI",
       
   150                 "SplitPaneUI", prefix + "SplitPaneUI",
       
   151                "TabbedPaneUI", prefix + "TabbedPaneUI",
       
   152               "TableHeaderUI", prefix + "TableHeaderUI",
       
   153                     "TableUI", prefix + "TableUI",
       
   154                  "TextAreaUI", prefix + "TextUI",
       
   155                 "TextFieldUI", prefix + "TextUI",
       
   156                  "TextPaneUI", prefix + "TextUI",
       
   157              "ToggleButtonUI", prefix + "ButtonUI",
       
   158          "ToolBarSeparatorUI", prefix + "SeparatorUI",
       
   159                   "ToolBarUI", prefix + "ToolBarUI",
       
   160                   "ToolTipUI", prefix + "ToolTipUI",
       
   161                      "TreeUI", prefix + "TreeUI",
       
   162                  "ViewportUI", prefix + "ViewportUI",
       
   163         };
       
   164 
       
   165         table.putDefaults(uiDefaults);
       
   166         return table;
       
   167     }
       
   168 
       
   169 }
       
   170 
       
   171 /**
       
   172  * We want the Test auxiliary look and feel to be quiet and fallback
       
   173  * gracefully if it cannot find a UI.  This class overrides the
       
   174  * getUIError method of UIDefaults, which is the method that
       
   175  * emits error messages when it cannot find a UI class in the
       
   176  * LAF.
       
   177  */
       
   178 class TestALFUIDefaults extends UIDefaults {
       
   179     protected void getUIError(String msg) {
       
   180         System.err.println("Test auxiliary L&F:  " + msg);
       
   181     }
       
   182 }