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:
26: /**
27: * A look and feel loader that knows how to work with the Default Look and Feel
28: *
29: * @author Jeff Tassin
30: */
31: class DefaultLoader implements LookAndFeelLoader {
32: public LookAndFeel createLookAndFeel(LookAndFeelInfo lfinfo) {
33: try {
34: if (lfinfo.getLookAndFeelClassName().indexOf(
35: "SubstanceLookAndFeel") >= 0) {
36: String jc_version = System
37: .getProperty("java.class.version");
38: float fval = Float.valueOf(jc_version).floatValue();
39: if (fval < 49.0f) {
40: return null;
41: }
42: }
43: Class c = Class.forName(lfinfo.getLookAndFeelClassName());
44: LookAndFeel result = (LookAndFeel) c.newInstance();
45: return result;
46: } catch (Throwable e) {
47: FormsLogger.debug(e);
48: }
49: return null;
50: }
51:
52: public void setLookAndFeel(LookAndFeelInfo lfinfo) {
53: try {
54: if (lfinfo.getLookAndFeel() != null)
55: UIManager.setLookAndFeel(lfinfo.getLookAndFeel());
56: } catch (Exception e) {
57: FormsLogger.debug(e);
58: }
59: }
60: }
|