01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.lookandfeel;
20:
21: import javax.swing.LookAndFeel;
22: import javax.swing.UIManager;
23:
24: import com.jeta.forms.logger.FormsLogger;
25: import com.jgoodies.looks.plastic.PlasticLookAndFeel;
26: import com.jgoodies.looks.plastic.PlasticTheme;
27:
28: /**
29: * A look and feel loader that knows how to work with the JGoodies Look and Feel
30: *
31: * @author Jeff Tassin
32: */
33: class JGoodiesLoader implements LookAndFeelLoader {
34: public LookAndFeel createLookAndFeel(LookAndFeelInfo lfinfo) {
35: try {
36: Class c = Class.forName(lfinfo.getLookAndFeelClassName());
37: return (LookAndFeel) c.newInstance();
38: } catch (Exception e) {
39: e.printStackTrace();
40: FormsLogger.debug(e);
41: }
42: return null;
43: }
44:
45: public void setLookAndFeel(LookAndFeelInfo lfinfo) {
46: try {
47: if (lfinfo.getLookAndFeel() != null) {
48: String theme = lfinfo.getTheme();
49: if (theme != null && theme.length() > 0) {
50: Class c = Class.forName(theme);
51: PlasticTheme ptheme = (PlasticTheme) c
52: .newInstance();
53: PlasticLookAndFeel.setMyCurrentTheme(ptheme);
54: }
55: UIManager.setLookAndFeel(lfinfo.getLookAndFeel());
56: }
57: } catch (Exception e) {
58: e.printStackTrace();
59: FormsLogger.debug(e);
60: }
61: }
62: }
|