OSDN Git Service

450faea30a618d301c8452459116ba60402fd222
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / Main.java
1 package yukihane.inqubus;
2
3 import java.nio.file.FileSystem;
4 import java.nio.file.FileSystems;
5 import java.nio.file.Path;
6 import java.util.logging.Level;
7 import java.util.logging.Logger;
8 import javax.swing.UIManager;
9 import javax.swing.UIManager.LookAndFeelInfo;
10 import javax.swing.UnsupportedLookAndFeelException;
11 import org.apache.commons.configuration.ConfigurationException;
12 import yukihane.inqubus.gui.MainFrame;
13
14 /**
15  * いんきゅばす起動クラス.
16  * @author yuki
17  */
18 public class Main {
19
20     private static final Logger logger = Logger.getLogger(Main.class.getName());
21
22     public static void main(String args[]) {
23         final FileSystem fileSystem = FileSystems.getDefault();
24         final Path path = fileSystem.getPath("inqubus.xml");
25         try {
26             Config.INSTANCE.load(path.toString());
27         } catch (ConfigurationException ex) {
28             logger.log(Level.FINE, "コンフィグファイルが無いためデフォルト値で起動", ex);
29         }
30         setLookAndFeel();
31         java.awt.EventQueue.invokeLater(new Runnable() {
32
33             public void run() {
34                 new MainFrame().setVisible(true);
35             }
36         });
37     }
38
39     private static void setLookAndFeel() {
40         try {
41             for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
42                 if ("Nimbus".equals(info.getName())) {
43                     UIManager.setLookAndFeel(info.getClassName());
44                     break;
45                 }
46             }
47         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
48             try {
49                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
50             } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
51                 // System Look & Feel も無いことは無いだろう
52             }
53         }
54     }
55 }