Package hexenschach

Source Code of hexenschach.Application

package hexenschach;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

import hexenschach.gui.Dictionary;
import hexenschach.gui.GUI;
import hexenschach.gui.QuestionDialog;
import hexenschach.gameplay.Persistence;


/**
* Enthaelt die main-Methode des Spiels,
* welche das GUI erzeugt und somit das Programm startet.
* @author Tobias Marquardt
*/
public class Application {
  public static int minXResolution = 1024;
  public static int minYResolution = 768;
  private static Persistence p;
  private static GUI gui;
  /**
   * @param args
   */
  public static void main(String[] args) {
    /*
    try {
    PrintStream fileStream = new PrintStream(new FileOutputStream("D:\\trace.txt"));
    System.setOut(fileStream);
    System.setErr(fileStream);
    } catch (FileNotFoundException fnfe) {
    } catch (SecurityException se) {
    }*/
   
    p = new Persistence();
    gui = new GUI(p);
    checkDisplayResolution();
    gui.start();
  }
  /**
   * Überprüft, ob die Bildschirmaufösung den Minimalanforderungen genügt.
   * Wenn nicht wird eine Warnung angezeigt und gefragt, ob das Spiel trotzdem
   * gestartet werden soll.
   */
  private static void checkDisplayResolution() {
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = environment.getDefaultScreenDevice();
    DisplayMode display = device.getDisplayMode();
    int x = display.getWidth();
    int y = display.getHeight();
    if(x < minXResolution || y < minYResolution) {
      QuestionDialog resolutionWarning = new QuestionDialog(gui, Dictionary.RelosutionDialogWarning) {
        private static final long serialVersionUID = -2534780214591239505L;
        @Override
        public void cancelButtonClicked() {
          System.exit(0);
        }
        @Override
        public void noButtonClicked() {
          System.exit(0);
        }
        @Override
        public void yesButtonClicked() {
          setVisible(false);
        }
      };
      resolutionWarning.setVisible(true);
    }
  }
}
TOP

Related Classes of hexenschach.Application

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.