001 /* PAVLOV -- Multiple Choice Study System
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/main/standalone/SkinSystem.java,v 1.3 2004/06/11 06:17:34 tj_willis Exp $
019 */
020 package net.sourceforge.pavlov.main.standalone;
021
022
023 import java.net.URL;
024 import org.apache.log4j.*;
025 import net.sourceforge.pavlov.main.*;
026 import java.awt.event.*;
027 import java.util.*;
028 import javax.swing.*;
029 import java.io.File;
030
031 /**
032
033 * @author <a href="mailto:tj_willis@users.sourceforge.net"></a>
034 * @version 1.0
035 */
036 public class SkinSystem
037 implements ActionListener {
038
039 Hashtable<String,Skin> skins = new Hashtable<String,Skin>();
040 SwingUIFactory uif;
041
042 public SkinSystem(SwingUIFactory uif, JMenu men) {
043 this.uif = uif;
044 JMenu skinsMenu = new JMenu("Skins");
045 File f = new File("resources/skins");
046 File files[] = f.listFiles();
047 ArrayList<File> dirs = new ArrayList<File>();
048
049 for( File g : files ){
050 if(g.isDirectory()){
051 File g2 = new File(g,"QuizPanel.vm");
052 if(g2.exists()){
053 dirs.add(g);
054 }
055 }
056 }
057
058 for( File g : dirs){
059 JMenuItem m = new JMenuItem(g.getName());
060 m.setActionCommand(g.getName());
061 m.addActionListener(this);
062 Skin k = new Skin(g);
063 skins.put(g.getName(),k);
064 skinsMenu.add(m);
065 }
066 men.add(skinsMenu);
067
068 }
069
070
071 /**
072 * Describe <code>actionPerformed</code> method here.
073 *
074 * @param e a <code>java.awt.event.ActionEvent</code> value
075 */
076 public void actionPerformed(java.awt.event.ActionEvent e) {
077 if(e==null)
078 return;
079 Object o = e.getSource();
080
081 if (o instanceof JMenuItem) {
082 uif.setTemplateToolkit(skins.get(e.getActionCommand()));
083 }
084 }
085
086
087
088
089 }