View Javadoc
1 package org.jface.vega.util; 2 3 import java.awt.Point; 4 import java.awt.Toolkit; 5 import java.awt.event.InputEvent; 6 7 import javax.swing.UIManager; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 /*** 13 * @author <a href="mailto:powerpete@users.sf.net">Moritz Petersen</a> 14 * @version $Id: SystemUtils.java,v 1.1 2004/02/09 12:35:34 powerpete Exp $ 15 */ 16 public class SystemUtils 17 { 18 private static final Log LOG = LogFactory.getLog(SystemUtils.class); 19 private static final Toolkit TOOLKIT = Toolkit.getDefaultToolkit(); 20 /*** 21 * The {@link #ALT} modifier represents the pressed ALT key. 22 */ 23 public static final int ALT = InputEvent.ALT_DOWN_MASK; 24 25 /*** 26 * The {@link #COMMAND} modifier represents the modifier, used to invoke 27 * default menu actions. It is platform dependent, so it represents the 28 * CTRL key on Windows and the APPLE key on the Macintosh, resp. 29 */ 30 public static final int COMMAND = TOOLKIT.getMenuShortcutKeyMask(); 31 32 /*** 33 * <tt>true</tt> if the client is a Macintosh. 34 */ 35 public static final boolean IS_MACINTOSH = 36 System.getProperty("mrj.version") != null; 37 38 /*** 39 * The {@link #SHIFT} modifier represents the pressed SHIFT key. 40 */ 41 public static final int SHIFT = InputEvent.SHIFT_DOWN_MASK; 42 43 /*** 44 * <tt>true</tt> if the client uses the Macintosh Aqua look and feel. 45 */ 46 public static final boolean USES_AQUA_LOOK_AND_FEEL = 47 IS_MACINTOSH 48 && UIManager.getSystemLookAndFeelClassName().equals( 49 UIManager.getLookAndFeel().getClass().getName()); 50 51 public static final String MAC_OS_X_USE_SCREEN_MENU_BAR = 52 "apple.laf.useScreenMenuBar"; 53 54 public static final String MAC_OS_X_MENU_ABOUT_NAME = 55 "com.apple.mrj.application.apple.menu.about.name"; 56 57 /*** 58 * Returns a changed {@link Point} representing the real position on the 59 * screen. It respects the screen menu bar. 60 * 61 * @param position The original {@link Point} 62 * @param gc The {@link GraphicsConfiguration} 63 * @return The changed position. 64 */ 65 public static Point getPositionOnScreen(Point position) 66 { 67 if (IS_MACINTOSH) 68 { 69 position.y += 22; 70 } 71 return position; 72 } 73 74 /*** 75 * Sets the system property if it is not already set. 76 * 77 * @param key 78 * @param value 79 */ 80 public static void safeSetProperty(String key, String value) 81 { 82 if (System.getProperty(key) == null) 83 { 84 System.setProperty(key, value); 85 } 86 } 87 88 /*** 89 * Sets the system's default look and feel. 90 */ 91 public static void setDefaultLookAndFeel() 92 { 93 String lookAndFeel = UIManager.getSystemLookAndFeelClassName(); 94 try 95 { 96 UIManager.setLookAndFeel(lookAndFeel); 97 } 98 catch (Exception e) 99 { 100 LOG.fatal("Error setting default look and feel.", e); 101 } 102 } 103 }

This page was automatically generated by Maven