Package com.idojaras

Source Code of com.idojaras.Main

/*******************************************************************************
* Copyright (c) 2014 Volcs�nyi Viktor Zsolt <lurko87@gmail.com>.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
*     Volcs�nyi Viktor Zsolt <lurko87@gmail.com> - initial API and implementation
******************************************************************************/
package com.idojaras;

import java.util.regex.Pattern;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

import org.apache.log4j.Logger;

import com.idojaras.core.view.MainFrame;
import com.idojaras.log.LoggerHelper;

public class Main {

  static Logger log = LoggerHelper.getInstance().createLogger(Main.class);

  public static void main(String[] args) {
    checkJVMVersion();
    SwingUtilities.invokeLater(new Runnable() {

      @Override
      public void run() {
        log.info("Starting application");
        try {
          for (LookAndFeelInfo info : UIManager
              .getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
              UIManager.setLookAndFeel(info.getClassName());
              break;
            }
          }
        } catch (Exception e) {
          // no nimbus theme
          log.warn(e.getMessage());
        }
        new MainFrame();
      }
    });
  }
  private static void checkJVMVersion() {
    String jvm = System.getProperty("java.specification.version");
    log.debug("Java version : " + jvm);

    Integer major = null;
    Integer minor = null;

    if (jvm.split(Pattern.quote(".")).length > 1) {
      try {
        major = Integer.valueOf(jvm.split(Pattern.quote("."))[0]);
        minor = Integer.valueOf(jvm.split(Pattern.quote("."))[1]);
      } catch (Exception ex) {
        log.warn(ex.getMessage(), ex);
      }
    }
    if (major != null && minor != null) {
      if (minor.intValue() < 7 && major.intValue() < 2) {
        log.fatal("Older JVM than 1.7");
        JOptionPane.showMessageDialog(new JFrame(),
            "A program fut�s�hoz minimum Java JRE 1.7 sz�ks�ges",
            "Hiba!", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
      }
    }
  }


}
TOP

Related Classes of com.idojaras.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.