OSDN Git Service

いんきゅばす起動処理
authoryukihane <yukihane.feather@gmail.com>
Wed, 24 Aug 2011 01:25:16 +0000 (10:25 +0900)
committeryukihane <yukihane.feather@gmail.com>
Wed, 24 Aug 2011 01:25:16 +0000 (10:25 +0900)
frontend/src/yukihane/inqubus/Main.java

index 4544bc7..9f18be9 100644 (file)
@@ -3,6 +3,13 @@ package yukihane.inqubus;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
+import java.util.logging.Logger;
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+import javax.swing.UnsupportedLookAndFeelException;
+import org.apache.commons.configuration.ConfigurationException;
+import yukihane.inqubus.config.Properties;
+import yukihane.inqubus.gui.MainFrame;
 
 /**
  * いんきゅばす起動クラス.
@@ -10,10 +17,55 @@ import java.nio.file.Path;
  */
 public class Main {
 
-    public static void main(String[] args) {
+    private static final Logger logger = Logger.getLogger(Main.class.getName());
+
+//    public static void main(String[] args) {
+//        final FileSystem fileSystem = FileSystems.getDefault();
+//        final Path path = fileSystem.getPath("inqubus.xml");
+//        try {
+//            Properties.INSTANCE.load(path.toString());
+//        } catch (ConfigurationException ex) {
+//            logger.info("コンフィグファイルが無いためデフォルト値で起動");
+//        }
+//
+//        SwingUtilities.invokeLater(new Runnable() {
+//
+//            @Override
+//            public void run() {
+//                final MainFrame frame = new MainFrame();
+//                frame.setVisible(true);
+//            }
+//        });
+//
+//    }
+    public static void main(String args[]) {
         final FileSystem fileSystem = FileSystems.getDefault();
         final Path path = fileSystem.getPath("inqubus.xml");
-        System.out.println(path.toAbsolutePath());
+        try {
+            Properties.INSTANCE.load(path.toString());
+        } catch (ConfigurationException ex) {
+            logger.info("コンフィグファイルが無いためデフォルト値で起動");
+        }
+
+        try {
+            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+                if ("Nimbus".equals(info.getName())) {
+                    UIManager.setLookAndFeel(info.getClassName());
+                    break;
+                }
+            }
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
+            try {
+                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
+                // System Look & Feel も無いことは無いだろう
+            }
+        }
+        java.awt.EventQueue.invokeLater(new Runnable() {
 
+            public void run() {
+                new MainFrame().setVisible(true);
+            }
+        });
     }
 }