01: package guam;
02:
03: import javax.swing.UIManager;
04: import java.awt.*;
05: import java.io.*;
06: import java.util.Vector;
07: import java.util.HashMap;
08: import java.util.Properties;
09:
10: public class GUAM {
11: boolean packFrame = false;
12: static Vector databases = null;
13: static String DBFilename = null;
14: static DBInterface dbi = new DBInterface();
15: static boolean DEBUG;
16:
17: /**Construct the application*/
18: public GUAM() {
19: try {
20: DBFilename = System.getProperty("guam.dbstore");
21: } catch (Exception E) {
22: DBFilename = "./guam.dat";
23: }
24:
25: try {
26: if (System.getProperty("guam.debug").equals("yes")) {
27: DEBUG = true;
28: } else {
29: DEBUG = false;
30: }
31: } catch (Exception E) {
32: DEBUG = false;
33: }
34:
35: loadDB();
36: MainFrame frame = new MainFrame(databases);
37: if (packFrame) {
38: frame.pack();
39: } else {
40: frame.validate();
41: }
42: //Center the window
43: Dimension screenSize = Toolkit.getDefaultToolkit()
44: .getScreenSize();
45: Dimension frameSize = frame.getSize();
46: if (frameSize.height > screenSize.height) {
47: frameSize.height = screenSize.height;
48: }
49: if (frameSize.width > screenSize.width) {
50: frameSize.width = screenSize.width;
51: }
52: frame.setLocation((screenSize.width - frameSize.width) / 2,
53: (screenSize.height - frameSize.height) / 2);
54: frame.setVisible(true);
55: }
56:
57: /**Main method*/
58: public static void main(String[] args) {
59: try {
60: UIManager.setLookAndFeel(UIManager
61: .getSystemLookAndFeelClassName());
62: } catch (Exception e) {
63: e.printStackTrace();
64: }
65: new GUAM();
66: }
67:
68: public static void loadDB() {
69: try {
70: ObjectInputStream i = new ObjectInputStream(
71: new FileInputStream(DBFilename));
72: databases = (Vector) i.readObject();
73: i.close();
74: } catch (Exception e) {
75: databases = new Vector();
76: System.out.println("Could not open DB file");
77: }
78: }
79:
80: public static void saveDB() {
81: try {
82: ObjectOutputStream o = new ObjectOutputStream(
83: new FileOutputStream(DBFilename));
84: o.writeObject(databases);
85: o.flush();
86: o.close();
87: } catch (Exception e) {
88: if (DEBUG) {
89: e.printStackTrace();
90: }
91: System.out.println("Could not save database parameters!");
92: }
93: }
94: }
|