Back to index

wims  3.65+svn20090927
LaunchApplet.java
Go to the documentation of this file.
00001 /*
00002     WIMSchem Elements: Chemistry molecular diagram drawing tool.
00003     
00004     (c) 2005 Dr. Alex M. Clark
00005     
00006     Released as GNUware, under the Gnu Public License (GPL)
00007     
00008     See www.gnu.org for details.
00009 */
00010 
00011 package WIMSchem;
00012 
00013 import java.io.*;
00014 import java.awt.*;
00015 import java.awt.event.*;
00016 import java.util.*;
00017 import javax.swing.*;
00018 // This launches the application from the applet...
00019 // so the added code is no good at all.
00020 public class LaunchApplet extends JApplet implements ActionListener
00021 {
00022     JButton openbutton;
00023     public Properties translation;
00024 
00025     public void init()
00026     {
00027         System.getProperty("java.version");
00028        String language = getParameter("language");
00029        if(language != null){language=language.toLowerCase();}else{language="en";}
00030        translation=loadProperties(language);
00031        openbutton=new JButton(translation.getProperty("Open_WIMSchem"));
00032        add(openbutton);
00033        openbutton.addActionListener(this);
00034     }
00035     
00036     public Properties loadProperties (String l){
00037        Properties P=new Properties();
00038        try{
00039            InputStream in = getClass().getResourceAsStream("/lang/WIMSchemProperties_"+l+".properties");
00040            P.load(in);in.close();
00041            return P;
00042        } 
00043        catch (Exception e){ System.out.println("error reading /lang/WIMSchemProperties_"+l+".properties\n"+e);}         
00044         return null;                                                                                                               
00045     }  
00046 
00047 
00048     public void actionPerformed(ActionEvent e) 
00049     {
00050        if (e.getSource()==openbutton)
00051        {
00052            MainWindow mw=new MainWindow(null,false,translation);
00053            mw.setVisible(true);
00054            System.out.println("foo");
00055        }
00056     }
00057 
00058     public String getAppletInfo() 
00059     {
00060        return translation.getProperty("WIMSchem_Applet_Description");
00061     }
00062 }
00063 
00064 
00065