package yukihane.inqubus; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.UnsupportedLookAndFeelException; import org.apache.commons.configuration.ConfigurationException; import yukihane.inqubus.gui.MainFrame; /** * いんきゅばす起動クラス. * @author yuki */ public class Main { 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"); boolean showWelcome; try { Config.INSTANCE.load(path.toString()); showWelcome = false; } catch (ConfigurationException ex) { showWelcome = true; logger.log(Level.FINER, "コンフィグファイルが無いためデフォルト値で起動", ex); } final RunWindow invoke = new RunWindow(showWelcome); java.awt.EventQueue.invokeLater(invoke); } private static class RunWindow implements Runnable { private final boolean showWelcome; private RunWindow(boolean showWelcome) { this.showWelcome = showWelcome; } @Override public void run() { setLookAndFeel(); final MainFrame frame = new MainFrame(); if(showWelcome) { JOptionPane.showMessageDialog(null, "設定はメニューの ツール > オプション から行えます", "いんきゅばすへようこそ", JOptionPane.INFORMATION_MESSAGE); } frame.startWatcher(); frame.setVisible(true); } } private static void setLookAndFeel() { 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 も無いことは無いだろう } } } }