load properties on startup
[jalview.git] / src / jalview / bin / Jalview.java
1 /********************\r
2  * 2004 Jalview Reengineered\r
3  * Barton Group\r
4  * Dundee University\r
5  *\r
6  * AM Waterhouse\r
7  *******************/\r
8 \r
9 \r
10 package jalview.bin;\r
11 \r
12 import jalview.gui.*;\r
13 import javax.swing.*;\r
14 import java.awt.event.*;\r
15 import jalview.io.*;\r
16 \r
17 \r
18 public class Jalview extends JApplet\r
19 {\r
20   public static JApplet applet;\r
21   Desktop frame;\r
22   public void init()\r
23   {\r
24     applet = this;\r
25 \r
26     frame = new Desktop();\r
27     frame.setResizable(true);\r
28     frame.setVisible(true);\r
29     frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);\r
30     frame.addWindowListener(new WindowAdapter()\r
31     {\r
32       public void windowClosing(WindowEvent e)\r
33       {\r
34           applet.stop();\r
35           applet.destroy();\r
36       }\r
37     });\r
38 \r
39     String file = getParameter("alignment");\r
40 \r
41     if(file!=null)\r
42     {\r
43       jalview.bin.Cache.setProperty("LAST_DIRECTORY", file);\r
44       String protocol = "File";\r
45       if (file.indexOf("http:") > -1)\r
46         protocol = "URL";\r
47 \r
48       String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
49 \r
50       frame.LoadFile(file, protocol, format);\r
51     }\r
52   }\r
53 \r
54   public void destroy()\r
55   {\r
56     if(applet!=null)\r
57       applet.stop();\r
58     else\r
59       System.exit(0);\r
60     frame.setVisible(false);\r
61   }\r
62 \r
63    public static void main(String[] args) {\r
64 \r
65     Cache.loadProperties();\r
66 \r
67     try{\r
68        UIManager.setLookAndFeel(\r
69    //   "javax.swing.plaf.metal.MetalLookAndFeel"\r
70     //  "javax.swing.plaf.multi.MultiLookAndFeel"\r
71          UIManager.getCrossPlatformLookAndFeelClassName()\r
72        // "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"\r
73        //   "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"\r
74        //  "com.sun.java.swing.plaf.motif.MotifLookAndFeel"\r
75      );\r
76      }\r
77      catch (Exception ex)\r
78      {}\r
79 \r
80     // JFrame.setDefaultLookAndFeelDecorated(true);\r
81      Desktop frame = new Desktop();\r
82      frame.setResizable(true);\r
83      frame.setVisible(true);\r
84 \r
85 \r
86      if(args!=null && args.length>0)\r
87      {\r
88          String file = args[0];\r
89          String protocol = "File";\r
90          if(file.indexOf("http:")>-1)\r
91            protocol = "URL";\r
92 \r
93          String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
94 \r
95          frame.LoadFile(file, protocol, format);\r
96      }\r
97 \r
98    }\r
99 \r
100 }\r
101 \r