Environment information. : Toolkit « Development Class « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java » Development Class » ToolkitScreenshots 
Environment information.
        
//package edu.northwestern.at.utils;

/*  Please see the license information at the end of this file. */

import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.awt.event.InputEvent;

/**
 * Environment information.
 */

public class Env {

  /** The operating system. */

  public static final String OSNAME = System.getProperty("os.name");

  /** True if running on Mac OS X. */

  public static final boolean MACOSX = System.getProperty("os.name").equals(
      "Mac OS X");

  /** True if running on some version of MS Windows. */

  public static final boolean WINDOWSOS = System.getProperty("os.name")
      .toLowerCase().startsWith("windows");

  /** True if running Java 2 level 1.3 or later. */

  public static final boolean IS_JAVA_13_OR_LATER = System.getProperty(
      "java.version").compareTo("1.3">= 0;

  /** True if running Java 2 level 1.4 or later. */

  public static final boolean IS_JAVA_14_OR_LATER = System.getProperty(
      "java.version").compareTo("1.4">= 0;

  /** True if running Java 2 level 1.4.2 or later. */

  public static final boolean IS_JAVA_142_OR_LATER = System.getProperty(
      "java.version").compareTo("1.4.2">= 0;

  /** True if running Java 2 level 1.5 or later. */

  public static final boolean IS_JAVA_15_OR_LATER = System.getProperty(
      "java.version").compareTo("1.5">= 0;

  /** True if running Java 2 level 1.6 or later. */

  public static final boolean IS_JAVA_16_OR_LATER = System.getProperty(
      "java.version").compareTo("1.6">= 0;

  /** True if running Java 2 level 1.7 or later. */

  public static final boolean IS_JAVA_17_OR_LATER = System.getProperty(
      "java.version").compareTo("1.7">= 0;

  /** Menu shortcut key mask. */

  public static int MENU_SHORTCUT_KEY_MASK;

  /** Menu shortcut key mask with shift key. */

  public static int MENU_SHORTCUT_SHIFT_KEY_MASK;

  /** Line separator. */

  public static final String LINE_SEPARATOR = System
      .getProperty("line.separator");

  static {
    // Do not initialize keyboard settings
    // if we are running headless.

    try {
      GraphicsEnvironment ge = GraphicsEnvironment
          .getLocalGraphicsEnvironment();

      if (!ge.isHeadless()) {
        MENU_SHORTCUT_KEY_MASK = Toolkit.getDefaultToolkit()
            .getMenuShortcutKeyMask();

        MENU_SHORTCUT_SHIFT_KEY_MASK = MENU_SHORTCUT_KEY_MASK
            + InputEvent.SHIFT_MASK;
      else {
        MENU_SHORTCUT_KEY_MASK = 0;
        MENU_SHORTCUT_SHIFT_KEY_MASK = 0;
      }
    catch (Exception e) {
    }
  }

  /** Don't allow instantiation, do allow overrides. */

  protected Env() {
  }
}

/*
 * Copyright (c) 2008, 2009 by Northwestern University. All rights reserved.
 
 * Developed by: Academic and Research Technologies Northwestern University
 * http://www.it.northwestern.edu/about/departments/at/
 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * with the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimers.
 
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimers in the documentation
 * and/or other materials provided with the distribution.
 
 * Neither the names of Academic and Research Technologies, Northwestern
 * University, nor the names of its contributors may be used to endorse or
 * promote products derived from this Software without specific prior written
 * permission.
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
 * THE SOFTWARE.
 */

   
    
    
    
    
    
    
    
  
Related examples in the same category
1.Check Desktop Property by using the Toolkit.getDefaultToolkit()
2.Use the getResourceAsStream method
3.Getting the Screen Size
4.Centering a Frame, Window, or Dialog on the Screen
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.