KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > configuration > lnf > ConfigSkinLnF


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.configuration.lnf;
20
21 import java.io.*;
22
23 import javax.swing.*;
24
25 import org.openharmonise.him.configuration.*;
26 import org.openharmonise.him.window.*;
27
28 import com.l2fprod.gui.plaf.skin.*;
29
30 /**
31  * Class to represent SkinLnF skin options.
32  *
33  * @author Matthew Large
34  * @version $Revision: 1.1 $
35  *
36  */

37 public class ConfigSkinLnF extends ConfigLnF {
38
39     /**
40      * Configuration dialog.
41      */

42     private ConfigDialog m_dialog = null;
43
44     /**
45      * Skin name
46      */

47     private String JavaDoc m_sTheme = null;
48
49     /**
50      * Constructs a new look and feel option.
51      *
52      * @param sTheme Skin name
53      * @param dialog Configuration dialog
54      */

55     public ConfigSkinLnF(String JavaDoc sTheme, ConfigDialog dialog) {
56         super();
57         this.m_dialog = dialog;
58         this.m_sTheme = sTheme;
59     }
60
61     /* (non-Javadoc)
62      * @see com.simulacramedia.contentmanager.configuration.lnf.ConfigLnF#setLookAndFeel()
63      */

64     public void setLookAndFeel() {
65         Skin skin = null;
66         try {
67             
68             InputStream is = ConfigSkinLnF.class.getResourceAsStream(m_sTheme);
69
70             skin = SkinLookAndFeel.loadThemePack( is );
71
72             SkinLookAndFeel.setSkin(skin);
73             SkinLookAndFeel.enable();
74             
75             String JavaDoc lookAndFeelClassName = "com.l2fprod.gui.plaf.skin.SkinLookAndFeel";
76             
77             UIManager.setLookAndFeel(lookAndFeelClassName);
78             
79             JFrame frame = DisplayManager.getInstance().getMainWindow();
80             
81             if(frame!=null) {
82                 SwingUtilities.updateComponentTreeUI(frame);
83             }
84             
85             if(this.m_dialog!=null) {
86                 SwingUtilities.updateComponentTreeUI(this.m_dialog);
87             }
88         } catch (UnsupportedLookAndFeelException e) {
89             e.printStackTrace();
90         } catch (ClassNotFoundException JavaDoc e) {
91             e.printStackTrace();
92         } catch (InstantiationException JavaDoc e) {
93             e.printStackTrace();
94         } catch (IllegalAccessException JavaDoc e) {
95             e.printStackTrace();
96         } catch (Exception JavaDoc e) {
97             e.printStackTrace();
98         }
99     }
100
101 }
102
Popular Tags