View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.plugin;
21  
22  import org.xnap.gui.*;
23  
24  import javax.swing.UIManager;
25  
26  /***
27   * Provides the default implementation for look and feel plugin classes.
28   */
29  public abstract class AbstractLAFPlugin extends AbstractPlugin
30  {
31  
32      //--- Constant(s) ---
33      
34      //--- Data Field(s) ---
35  
36  	private String className;
37  
38      //--- Constructor(s) ---
39  
40  	public AbstractLAFPlugin(String className)
41  	{
42  		this.className = className;
43  	}
44  
45  	public AbstractLAFPlugin()
46  	{
47  	}
48  
49      //--- Method(s) ---
50     
51      /***
52  	 * Registers the Look And Feel. We need to do this before the gui is
53  	 * started (except for the SplashWindow).
54  	 *
55       * @see Plugin#start()
56       */
57      public void start()
58      {
59  		installLookAndFeel();
60      }
61  
62      /***
63  	 * Updates the look and feel menu.
64  	 *
65       * @see Plugin#startGUI()
66       */
67      public void startGUI()
68      {
69  		XNapFrame.getInstance().getMainMenuBar().updateLookAndFeels();
70      }
71  
72      /***
73  	 * Does nothing.
74  	 *
75       * @see Plugin#stop()
76       */
77      public void stop()
78      {
79      }
80  
81      /***
82  	 * Updates the look and feel menu.
83  	 *
84       * @see Plugin#stopGUI()
85       */
86      public void stopGUI()
87      {
88  		XNapFrame.getInstance().getMainMenuBar().updateLookAndFeels();
89      }
90  
91      public void installLookAndFeel()
92      {
93  		if (className != null) {
94  			UIManager.installLookAndFeel(getInfo().getName(), className);
95  		}
96  	}
97  
98  //  		// some look and feels install themselfs in their constructor
99  //  		// therefore we collect all look and feels first and then
100 //  		// check if they are installed already
101 //  		UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
102 //  		if (info != null) {
103 //  			for (int i = 0; i < info.length; i++) {
104 //  				lafsByClassName.remove(info[i].getClassName());
105 //  			}
106 //  		}
107 
108 //  		for (Iterator i = lafsByClassName.values().iterator(); i.hasNext();) {
109 //  			UIManager.installLookAndFeel((UIManager.LookAndFeelInfo)i.next());
110 //  		}
111 
112 //  		}
113 //  		catch (Exception e) {
114 //  		}
115 
116 }