Java Swing UIManager getSystemDefaultModifier()

Here you can find the source of getSystemDefaultModifier()

Description

gives default modifier of the current OS.

License

Open Source License

Return

meta (command) for OSX, control for Windows/Linux etc

Declaration

public static int getSystemDefaultModifier() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2010 BREDEX GmbH.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w  w w  .  j av a 2 s.  co  m*/
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
 *******************************************************************************/

import java.awt.Event;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.UIManager;

public class Main {
    /**
     * ID of Metal Look and Feel.
     */
    private static final String METAL_LAF_ID = "Metal";

    /**
     * gives default modifier of the current OS.
     * 
     * @return meta (command) for OSX, control for Windows/Linux etc 
     */
    public static int getSystemDefaultModifier() {
        if (!(UIManager.getLookAndFeel().getID().equals(METAL_LAF_ID))) {
            int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
            if (mask == Event.META_MASK) {
                return KeyEvent.VK_META;
            } else if (mask == Event.ALT_MASK) {
                return KeyEvent.VK_ALT;
            }
        }
        return KeyEvent.VK_CONTROL;
    }
}

Related

  1. getNimbusClassName()
  2. getPropertyMaxGutterIconWidth(final String propertyPrefix)
  3. getRowHeight(java.awt.Component c)
  4. getSeparator()
  5. getStringWidth(final String aString)
  6. getTitleBarIcon()
  7. getToolTipBackground()
  8. getToolTipBackground()
  9. getToolTipForeground()