KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jgoodies > looks > windows > WindowsLookAndFeel


1 /*
2  * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * o Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * o Neither the name of JGoodies Karsten Lentzsch nor the names of
15  * its contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.jgoodies.looks.windows;
32
33 import java.awt.Color JavaDoc;
34 import java.awt.Font JavaDoc;
35 import java.lang.reflect.Method JavaDoc;
36
37 import javax.swing.Icon JavaDoc;
38 import javax.swing.UIDefaults JavaDoc;
39 import javax.swing.border.Border JavaDoc;
40 import javax.swing.plaf.DimensionUIResource JavaDoc;
41 import javax.swing.plaf.FontUIResource JavaDoc;
42 import javax.swing.plaf.InsetsUIResource JavaDoc;
43 import javax.swing.plaf.basic.BasicBorders JavaDoc;
44
45 import com.jgoodies.looks.FontSizeHints;
46 import com.jgoodies.looks.FontUtils;
47 import com.jgoodies.looks.LookUtils;
48 import com.jgoodies.looks.Options;
49 import com.jgoodies.looks.common.MinimumSizedIcon;
50 import com.jgoodies.looks.common.ShadowPopupFactory;
51
52 /**
53  * The main class of the JGoodies Windows Look&Feel.
54  * This look provides several corrections and extensions to Sun's Windows L&F.
55  * In addition it tries to provide a unified look for the J2SE 1.4.0x, 1.4.1x,
56  * 1.4.2, and 1.5 environments.
57  *
58  * @author Karsten Lentzsch
59  * @version $Revision: 1.6 $
60  */

61 public final class WindowsLookAndFeel extends com.sun.java.swing.plaf.windows.WindowsLookAndFeel {
62
63     /**
64      * Client property key to set a border style - shadows the header style.
65      * */

66     public static final String JavaDoc BORDER_STYLE_KEY = "jgoodies.windows.borderStyle";
67
68     // The look dependent fontSizeHints
69
private static FontSizeHints fontSizeHints = null;
70
71     public String JavaDoc getID() {
72         return "JGoodies Windows";
73     }
74
75     public String JavaDoc getName() {
76         return "JGoodies Windows";
77     }
78
79     public String JavaDoc getDescription() {
80         return "The JGoodies Windows Look and Feel"
81                 + " - \u00a9 2001-2005 JGoodies Karsten Lentzsch";
82     }
83
84     // Special Properties ***************************************************
85

86     /**
87      * Returns the current <code>FontSizeHints</code>; look specific
88      * settings shadow the global users defaults as stored under
89      * key <code>FontSizeHints.KEY</code>.
90      *
91      * @return the current FontSizeHints, either this L&amp;Fs local hints,
92      * or the global hints if no local hints are available
93      * @see Options#setGlobalFontSizeHints(FontSizeHints)
94      * @see FontSizeHints
95      */

96     public static FontSizeHints getFontSizeHints() {
97         return fontSizeHints != null
98             ? fontSizeHints
99             : Options.getGlobalFontSizeHints();
100     }
101
102     /**
103      * Sets <code>FontSizeHints</code> that shadow the global font size hints.
104      *
105      * @see Options#setGlobalFontSizeHints(FontSizeHints)
106      * @see FontSizeHints
107      */

108     public static void setFontSizeHints(FontSizeHints newHints) {
109         fontSizeHints = newHints;
110     }
111     
112
113     // Overriding Superclass Behavior ***************************************
114

115     /**
116      * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
117      * to the superclass behavior, we install the ShadowPopupFactory.
118      *
119      * @see #uninitialize
120      */

121     public void initialize() {
122         super.initialize();
123         ShadowPopupFactory.install();
124     }
125     
126     
127     /**
128      * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
129      * to the superclass behavior, we uninstall the ShadowPopupFactory.
130      *
131      * @see #initialize
132      */

133     public void uninitialize() {
134         super.uninitialize();
135         ShadowPopupFactory.uninstall();
136     }
137     
138     
139     /**
140      * Initializes the class defaults, that is, overrides some UI delegates
141      * with JGoodies Windows implementations.
142      */

143     protected void initClassDefaults(UIDefaults JavaDoc table) {
144         super.initClassDefaults(table);
145         String JavaDoc WINDOWS_PREFIX = "com.jgoodies.looks.windows.Windows";
146         String JavaDoc COMMON_PREFIX = "com.jgoodies.looks.common.ExtBasic";
147
148         String JavaDoc menuUIPrefix = LookUtils.IS_LAF_WINDOWS_XP_ENABLED
149                 ? WINDOWS_PREFIX
150                 : COMMON_PREFIX;
151
152         // Overwrite some of the uiDefaults.
153
Object JavaDoc[] uiDefaults = {
154         // Can use narrow margins
155
"ButtonUI", WINDOWS_PREFIX + "ButtonUI",
156             "ToggleButtonUI", WINDOWS_PREFIX + "ToggleButtonUI",
157
158             // Modified size
159
"ComboBoxUI", WINDOWS_PREFIX + "ComboBoxUI",
160
161             // Can installs an optional etched border
162
"ScrollPaneUI", WINDOWS_PREFIX + "ScrollPaneUI",
163
164             // Optional style and optional special borders
165
"MenuBarUI", WINDOWS_PREFIX + "MenuBarUI",
166
167             // Aligned menu items
168
"MenuUI", menuUIPrefix + "MenuUI",
169             "MenuItemUI", COMMON_PREFIX + "MenuItemUI",
170             "CheckBoxMenuItemUI", COMMON_PREFIX + "CheckBoxMenuItemUI",
171             "RadioButtonMenuItemUI", COMMON_PREFIX + "RadioButtonMenuItemUI",
172
173             // Has padding above and below the separator lines
174
"PopupMenuSeparatorUI", COMMON_PREFIX + "PopupMenuSeparatorUI",
175
176             // Honors the screen resolution and uses a minimum button width
177
"OptionPaneUI", WINDOWS_PREFIX + "OptionPaneUI",
178
179             // 1.4.1 has ugly one touch triangles
180
"SplitPaneUI", WINDOWS_PREFIX + "SplitPaneUI",
181
182             // Work in progress: Can have a flat presentation
183
"TabbedPaneUI", WINDOWS_PREFIX + "TabbedPaneUI",
184
185             // Corrected position of the tree button icon
186
"TreeUI", WINDOWS_PREFIX + "TreeUI",
187             
188             // Just to use shared UI delegate
189
"SeparatorUI", WINDOWS_PREFIX + "SeparatorUI"};
190
191         if (LookUtils.IS_JAVA_1_4_2_OR_LATER) {
192             // Modified Border
193
uiDefaults = append(uiDefaults,
194             "SpinnerUI", WINDOWS_PREFIX + "SpinnerUI");
195         }
196         
197    
198         if (LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
199             // Renders a circle, not the star ("*") character
200
uiDefaults = append(uiDefaults,
201                 "PasswordFieldUI", WINDOWS_PREFIX + "XPPasswordFieldUI");
202
203             // Optional style and optional special borders;
204
// rollover borders for compound buttons
205
uiDefaults = append(uiDefaults,
206                 "ToolBarUI", WINDOWS_PREFIX + "XPToolBarUI");
207             
208             // Honors XP table header style for custom user renderers.
209
uiDefaults = append(uiDefaults,
210                 "TableHeaderUI", WINDOWS_PREFIX + "XPTableHeaderUI");
211         } else {
212             // Optional style and optional special borders;
213
// rollover borders corrected
214
uiDefaults = append(uiDefaults,
215                 "ToolBarUI", WINDOWS_PREFIX + "ToolBarUI");
216
217             // Black arrows
218
uiDefaults = append(uiDefaults,
219                 "ScrollBarUI", WINDOWS_PREFIX + "ScrollBarUI");
220
221             if (!LookUtils.IS_JAVA_1_4_2_OR_LATER) {
222                 // Uses unmodified size specified by "ToolBar.separatorSize"
223
uiDefaults = append(uiDefaults,
224                         "ToolBarSeparatorUI", WINDOWS_PREFIX + "ToolBarSeparatorUI");
225             }
226         }
227         table.putDefaults(uiDefaults);
228     }
229
230     /**
231      * Initializes the component defaults.
232      */

233     protected void initComponentDefaults(UIDefaults JavaDoc table) {
234         super.initComponentDefaults(table);
235         
236         final boolean isXP = LookUtils.IS_LAF_WINDOWS_XP_ENABLED;
237
238         // Override font settings if and only if we are allowed to.
239
if (FontUtils.useSystemFontSettings()) {
240             initFontDefaults(table);
241         }
242
243         if (!isXP) {
244             initComponentDefaultsNoXP(table);
245         }
246
247         Object JavaDoc marginBorder = new BasicBorders.MarginBorder JavaDoc();
248         Object JavaDoc checkBoxMargin = new InsetsUIResource JavaDoc(2, 0, 2, 0);
249
250         Object JavaDoc etchedBorder = new UIDefaults.ProxyLazyValue JavaDoc(
251                 "javax.swing.plaf.BorderUIResource",
252                 "getEtchedBorderUIResource");
253         Object JavaDoc buttonBorder = new SimpleProxyLazyValue(
254                 "com.jgoodies.looks.windows.WindowsLookAndFeel",
255                 "getButtonBorder");
256         Object JavaDoc menuBorder = WindowsBorders.getMenuBorder();
257
258         Object JavaDoc menuBarEmptyBorder = marginBorder;
259         Object JavaDoc menuBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
260         Object JavaDoc menuBarEtchedBorder = WindowsBorders.getEtchedBorder();
261         Object JavaDoc menuBarHeaderBorder = WindowsBorders.getMenuBarHeaderBorder();
262
263         Object JavaDoc toolBarEmptyBorder = marginBorder;
264         Object JavaDoc toolBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
265         Object JavaDoc toolBarEtchedBorder = WindowsBorders.getEtchedBorder();
266         Object JavaDoc toolBarHeaderBorder = WindowsBorders.getToolBarHeaderBorder();
267
268         Object JavaDoc defaultButtonMargin = LookUtils.createButtonMargin(false);
269         Object JavaDoc narrowButtonMargin = LookUtils.createButtonMargin(true);
270
271         Object JavaDoc toolBarSeparatorSize = LookUtils.IS_JAVA_1_4_2_OR_LATER
272             ? null
273             : new DimensionUIResource JavaDoc(6, Options.getDefaultIconSize().height);
274
275         Object JavaDoc textInsets = new InsetsUIResource JavaDoc(2, 2, 2, 2);
276         
277         Object JavaDoc comboRendererMargin = LookUtils.IS_JAVA_1_4
278             ? textInsets
279             : new InsetsUIResource JavaDoc(0, 0, 0, 0);
280
281         Object JavaDoc menuItemMargin = LookUtils.IS_LOW_RESOLUTION
282                 ? new InsetsUIResource JavaDoc(3, 0, 3, 0)
283                 : new InsetsUIResource JavaDoc(2, 0, 2, 0);
284         Object JavaDoc menuMargin = LookUtils.IS_LOW_RESOLUTION
285                 ? new InsetsUIResource JavaDoc(2, 3, 2, 3)
286                 : new InsetsUIResource JavaDoc(2, 4, 2, 4);
287
288         int pad = isXP ? 3 : 0;
289         Object JavaDoc popupMenuSeparatorMargin = LookUtils.IS_LOW_RESOLUTION
290                 ? new InsetsUIResource JavaDoc(2, pad, 3, pad)
291                 : new InsetsUIResource JavaDoc(3, pad, 4, pad);
292
293         Icon JavaDoc menuItemCheckIcon = new MinimumSizedIcon();
294
295         // Should be active.
296
int treeFontSize = table.getFont("Tree.font").getSize();
297         Integer JavaDoc rowHeight = new Integer JavaDoc(treeFontSize + 6);
298
299         Class JavaDoc superclass = getClass().getSuperclass();
300         Color JavaDoc controlColor = table.getColor("control");
301
302         Object JavaDoc menuBarBackground = isXP
303                 ? table.get("control")
304                 : table.get("menu");
305         Object JavaDoc menuSelectionBackground = isXP
306                 ? table.get("MenuItem.selectionBackground")
307                 : table.get("Menu.background");
308         Object JavaDoc menuSelectionForeground = isXP
309                 ? table.get("MenuItem.selectionForeground")
310                 : table.get("Menu.foreground");
311         
312         Object JavaDoc[] defaults = {
313             "Button.border", buttonBorder,
314             "Button.margin", defaultButtonMargin, // 1.4.1 Bug
315
"Button.narrowMargin", narrowButtonMargin, // Added by JGoodies
316

317             // 1.4.2 uses a 2 pixel non-standard border, that leads to bad
318
// alignment in the typical case that the border is not painted
319
"CheckBox.border", marginBorder,
320             "CheckBox.margin", checkBoxMargin,
321             
322             "ComboBox.editorBorder", marginBorder,
323             "ComboBox.editorColumns", new Integer JavaDoc(5),
324             "ComboBox.rendererMargin", comboRendererMargin, // Added by JGoodies
325

326             "EditorPane.margin", textInsets,
327             
328             // InternalFrame
329
"InternalFrame.icon", makeIcon(superclass, "icons/JavaCup.gif"),
330             
331             
332             // Begin 1.3 und 1.4.0
333
"Menu.border", menuBorder, // Fixed in 1.4.1
334
"Menu.borderPainted", Boolean.TRUE,
335             "Menu.background", menuBarBackground,
336             "Menu.selectionForeground", menuSelectionForeground,
337             "Menu.selectionBackground", menuSelectionBackground,
338             // End 1.3 und 1.4.0
339

340             "Menu.margin", menuMargin, // 1.4.1 Bug
341

342             "MenuBar.background", menuBarBackground,
343             "MenuBar.border", menuBarSeparatorBorder, // 1.4.1 Separator wrong
344
"MenuBar.emptyBorder", menuBarEmptyBorder, // Added by JGoodies
345
"MenuBar.separatorBorder", menuBarSeparatorBorder, // Added by JGoodies
346
"MenuBar.etchedBorder", menuBarEtchedBorder, // Added by JGoodies
347
"MenuBar.headerBorder", menuBarHeaderBorder, // Added by JGoodies
348

349             "MenuItem.borderPainted", Boolean.TRUE,
350             "MenuItem.checkIcon", menuItemCheckIcon, // Aligns menu items
351
"MenuItem.margin", menuItemMargin, // 1.4.1 Bug
352
"CheckBoxMenuItem.margin", menuItemMargin, // 1.4.1 Bug
353
"RadioButtonMenuItem.margin", menuItemMargin, // 1.4.1 Bug
354

355             "OptionPane.errorIcon", isXP ? makeIcon(getClass(), "icons/xp/Error.png")
356                                                : makeIcon(superclass, "icons/Error.gif"),
357             "OptionPane.informationIcon", isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
358                                                : makeIcon(superclass, "icons/Inform.gif"),
359             "OptionPane.warningIcon", isXP ? makeIcon(getClass(), "icons/xp/Warn.png")
360                                                : makeIcon(superclass, "icons/Warn.gif"),
361             "OptionPane.questionIcon", isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
362                                                : makeIcon(superclass, "icons/Question.gif"),
363             "FormattedTextField.margin", textInsets, // 1.4.1 Bug
364
"PasswordField.margin", textInsets, // 1.4.1 Bug
365

366             "PopupMenu.border", WindowsBorders.getPopupMenuBorder(),
367             "PopupMenuSeparator.margin", popupMenuSeparatorMargin,
368
369             "ScrollPane.etchedBorder", etchedBorder, // Added by JGoodies
370

371             // 1.4.1 uses a 2 pixel non-standard border, that leads to bad
372
// alignment in the typical case that the border is not painted
373
"RadioButton.border", marginBorder,
374             "RadioButton.margin", checkBoxMargin,
375             
376             "Table.gridColor", controlColor, // 1.4.1 Bug; active
377
"TextArea.margin", textInsets, // 1.4.1 Bug
378
"TextField.margin", textInsets, // 1.4.1 Bug
379
"ToggleButton.margin", defaultButtonMargin, // 1.4.1 Bug
380
"ToggleButton.narrowMargin", narrowButtonMargin, // Added by JGoodies
381

382             "ToolBar.border", toolBarEmptyBorder,
383             "ToolBar.emptyBorder", toolBarEmptyBorder, // Added by JGoodies
384
"ToolBar.separatorBorder", toolBarSeparatorBorder, // Added by JGoodies
385
"ToolBar.etchedBorder", toolBarEtchedBorder, // Added by JGoodies
386
"ToolBar.headerBorder", toolBarHeaderBorder, // Added by JGoodies
387
"ToolBar.separatorSize", toolBarSeparatorSize,
388             "ToolBar.margin", new InsetsUIResource JavaDoc(0, 10, 0, 0),
389
390             "Tree.selectionBorderColor", controlColor, // 1.4.1 Bug; active
391
"Tree.rowHeight", rowHeight, // 1.4.1 Bug
392
"Tree.openIcon", isXP ? makeIcon(getClass(), "icons/xp/TreeOpen.png")
393                                                : makeIcon(getClass(), "icons/TreeOpen.gif"),
394             "Tree.closedIcon", isXP ? makeIcon(getClass(), "icons/xp/TreeClosed.png")
395                                                : makeIcon(getClass(), "icons/TreeClosed.gif"),
396         };
397         table.putDefaults(defaults);
398     }
399
400     /**
401      * Initializes component defaults required in 1.3 runtime environments only.
402      */

403     private void initComponentDefaultsNoXP(UIDefaults JavaDoc table) {
404         Object JavaDoc checkBoxIcon = new SimpleProxyLazyValue(
405                 "com.jgoodies.looks.windows.WindowsLookAndFeel",
406                 "getCheckBoxIcon");
407
408         Object JavaDoc radioButtonIcon = new SimpleProxyLazyValue(
409                 "com.jgoodies.looks.windows.WindowsLookAndFeel",
410                 "getRadioButtonIcon");
411
412         Border JavaDoc winInsetBorder = new BasicBorders.FieldBorder JavaDoc(table
413                 .getColor("controlShadow"), table
414                 .getColor("controlDkShadow"),
415                 table.getColor("controlHighlight"), table
416                         .getColor("controlLtHighlight"));
417
418         Object JavaDoc[] defaults = {
419             "CheckBox.checkColor", table.get("controlText"), // kind-of black
420
"CheckBox.icon", checkBoxIcon,
421             "RadioButton.checkColor", table.get("controlText"), // kind-of black
422
"RadioButton.icon", radioButtonIcon,
423             "Table.scrollPaneBorder", winInsetBorder, // 1.4.1 Bug
424

425         };
426         table.putDefaults(defaults);
427     }
428
429     /**
430      * Initializes the font defaults.
431      * Uses the superclass' menu font (often Tahoma) in a smaller size
432      * as control font and overrides the TextArea font with control font.
433      */

434     private void initFontDefaults(UIDefaults JavaDoc table) {
435         Font JavaDoc messageFont;
436         Font JavaDoc toolTipFont;
437         Font JavaDoc windowFont;
438
439         // Look up the (modified) menu font and control font.
440
Font JavaDoc menuFont = FontUtils.getMenuFont(table, getFontSizeHints());
441         Font JavaDoc controlFont = FontUtils.getControlFont(table, getFontSizeHints());
442
443         // Derive a bold version of the control font.
444
Font JavaDoc controlBoldFont = new FontUIResource JavaDoc(controlFont
445                 .deriveFont(Font.BOLD));
446
447         messageFont = table.getFont("OptionPane.font");
448         toolTipFont = table.getFont("ToolTip.font");
449         windowFont = table.getFont("InternalFrame.titleFont");
450
451         FontUtils.initFontDefaults(table, controlFont, controlBoldFont,
452                 controlFont, menuFont, messageFont, toolTipFont, windowFont);
453     }
454
455     // Getters for Proxy Access (Referred classes can stay package visible) ***
456

457     public static Border JavaDoc getButtonBorder() {
458         return WindowsBorders.getButtonBorder();
459     }
460
461     public static Icon JavaDoc getCheckBoxIcon() {
462         return WindowsIconFactory.getCheckBoxIcon();
463     }
464
465     public static Icon JavaDoc getRadioButtonIcon() {
466         return WindowsIconFactory.getRadioButtonIcon();
467     }
468     
469     // Helper Code ************************************************************
470

471     /**
472      * Appends the key and value to the given source array and returns
473      * a copy that has the two new elements at its end.
474      *
475      * @return an array with the key and value appended
476      */

477     private static Object JavaDoc[] append(Object JavaDoc[] source, String JavaDoc key, Object JavaDoc value) {
478         int length = source.length;
479         Object JavaDoc[] destination = new Object JavaDoc[length + 2];
480         System.arraycopy(source, 0, destination, 0, length);
481         destination[length] = key;
482         destination[length + 1] = value;
483         return destination;
484     }
485
486     // Helper Class ***********************************************************
487

488     /**
489      * This class provides an implementation of <code>LazyValue</code> that
490      * can be used to delay loading of the Class for the instance to be created.
491      * It also avoids creation of an anonymous inner class for the
492      * <code>LazyValue</code>
493      * subclass. Both of these improve performance at the time that a
494      * a Look and Feel is loaded, at the cost of a slight performance
495      * reduction the first time <code>createValue</code> is called
496      * (since Reflection APIs are used).
497      */

498     private static class SimpleProxyLazyValue implements UIDefaults.LazyValue JavaDoc {
499
500         private final String JavaDoc className;
501         private final String JavaDoc methodName;
502
503         /**
504          * Creates a <code>LazyValue</code> which will construct an instance
505          * when asked.
506          *
507          * @param c a <code>String</code> specifying the classname of the class
508          * containing a static method to be called for instance creation
509          * @param m a <code>String</code> specifying the static
510          * method to be called on class c
511          */

512         public SimpleProxyLazyValue(String JavaDoc c, String JavaDoc m) {
513             className = c;
514             methodName = m;
515         }
516
517         /**
518          * Creates the value retrieved from the <code>UIDefaults</code> table.
519          * The object is created each time it is accessed.
520          *
521          * @param table a <code>UIDefaults</code> table
522          * @return the created <code>Object</code>
523          */

524         public Object JavaDoc createValue(UIDefaults JavaDoc table) {
525             Object JavaDoc instance = null;
526             try {
527                 Class JavaDoc c;
528                 // We use a separate ClassLoader
529
ClassLoader JavaDoc classLoader = table != null
530                         ? (ClassLoader JavaDoc) table.get("ClassLoader")
531                         : Thread.currentThread().getContextClassLoader();
532                 if (classLoader == null) {
533                     classLoader = getClass().getClassLoader();
534                 }
535                 c = Class.forName(className, true, classLoader);
536                 Method JavaDoc m = c.getMethod(methodName, null);
537                 instance = m.invoke(c, null);
538             } catch (Throwable JavaDoc t) {
539                 LookUtils.log("Problem creating " + className + " with method "
540                         + methodName + t);
541             }
542             return instance;
543         }
544     }
545
546 }
Popular Tags