Package net.suncrescent.clicker.util

Source Code of net.suncrescent.clicker.util.Environment

package net.suncrescent.clicker.util;

import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Environment {

  private static Environment instance;
  private final Dimension screenSize;

  private Environment() {

    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();
    DisplayMode displayMode = dev.getDisplayMode();

    this.screenSize = new Dimension(displayMode.getWidth(), displayMode.getHeight());
  }

  public static Dimension getScreenSize() {
    if (instance == null) {
      instance = new Environment();
    }

    // create new copy to prevent any changes
    return new Dimension(instance.screenSize);
  }
}
TOP

Related Classes of net.suncrescent.clicker.util.Environment

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.