diff --git a/src/main/java/com/melloware/jintellitype/JIntellitype.java b/src/main/java/com/melloware/jintellitype/JIntellitype.java index afc40b7..1b328fb 100644 --- a/src/main/java/com/melloware/jintellitype/JIntellitype.java +++ b/src/main/java/com/melloware/jintellitype/JIntellitype.java @@ -28,16 +28,14 @@ import java.util.concurrent.CopyOnWriteArrayList; import javax.swing.SwingUtilities; /** - * JIntellitype A Java Implementation for using the Windows API Intellitype - * commands and the RegisterHotKey and UnRegisterHotkey API calls for globally - * responding to key events. Intellitype are commands that are using for Play, + * JIntellitype A Java Implementation for using the Windows API Intellitype commands and the RegisterHotKey and + * UnRegisterHotkey API calls for globally responding to key events. Intellitype are commands that are using for Play, * Stop, Next on Media keyboards or some laptops that have those special keys. *
- * JIntellitype class that is used to call Windows API calls using the - * JIntellitype.dll. + * JIntellitype class that is used to call Windows API calls using the JIntellitype.dll. *
- * This file comes with native code in JINTELLITYPE.DLL The DLL should go in - * C:/WINDOWS/SYSTEM or in your current directory + * This file comes with native code in JINTELLITYPE.DLL The DLL should go in C:/WINDOWS/SYSTEM or in your current + * directory *
*
* Copyright (c) 1999-2008 Melloware, Inc.
- * But the possibility of creation of more instance is only before the
- * instance is created. Since all code defined inside getInstance method is
- * in the synchronized block, even the subsequent requests will also come and
- * wait in the synchronized block. This is a performance issue. The same can
- * be solved using double-checked lock. Following is the implementation of
- * Singleton with lazy initialization and double-checked lock.
+ * But the possibility of creation of more instance is only before the instance is created. Since all code defined
+ * inside getInstance method is in the synchronized block, even the subsequent requests will also come and wait in
+ * the synchronized block. This is a performance issue. The same can be solved using double-checked lock. Following
+ * is the implementation of Singleton with lazy initialization and double-checked lock.
*
* @return an instance of JIntellitype class
*/
@@ -212,13 +203,11 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Registers a Hotkey with windows. This combination will be responded to by
- * all registered HotKeyListeners. Uses the JIntellitypeConstants for MOD,
- * ALT, CTRL, and WINDOWS keys.
+ * Registers a Hotkey with windows. This combination will be responded to by all registered HotKeyListeners. Uses the
+ * JIntellitypeConstants for MOD, ALT, CTRL, and WINDOWS keys.
*
* @param identifier a unique identifier for this key combination
- * @param modifier MOD_SHIFT, MOD_ALT, MOD_CONTROL, MOD_WIN from
- * JIntellitypeConstants, or 0 if no modifier needed
+ * @param modifier MOD_SHIFT, MOD_ALT, MOD_CONTROL, MOD_WIN from JIntellitypeConstants, or 0 if no modifier needed
* @param keycode the key to respond to in Ascii integer, 65 for A
*/
public void registerHotKey(int identifier, int modifier, int keycode) {
@@ -236,13 +225,11 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Registers a Hotkey with windows. This combination will be responded to by
- * all registered HotKeyListeners. Use the Swing InputEvent constants from
- * java.awt.InputEvent.
+ * Registers a Hotkey with windows. This combination will be responded to by all registered HotKeyListeners. Use the
+ * Swing InputEvent constants from java.awt.InputEvent.
*
* @param identifier a unique identifier for this key combination
- * @param modifier InputEvent.SHIFT_MASK, InputEvent.ALT_MASK,
- * InputEvent.CTRL_MASK, or 0 if no modifier needed
+ * @param modifier InputEvent.SHIFT_MASK, InputEvent.ALT_MASK, InputEvent.CTRL_MASK, or 0 if no modifier needed
* @param keycode the key to respond to in Ascii integer, 65 for A
*/
public void registerSwingHotKey(int identifier, int modifier, int keycode) {
@@ -256,13 +243,11 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Registers a Hotkey with windows. This combination will be responded to by
- * all registered HotKeyListeners. Use the identifiers CTRL, SHIFT, ALT
- * and/or WIN.
+ * Registers a Hotkey with windows. This combination will be responded to by all registered HotKeyListeners. Use the
+ * identifiers CTRL, SHIFT, ALT and/or WIN.
*
* @param identifier a unique identifier for this key combination
- * @param modifierAndKeyCode String with modifiers separated by + and keycode
- * (e.g. CTRL+SHIFT+A)
+ * @param modifierAndKeyCode String with modifiers separated by + and keycode (e.g. CTRL+SHIFT+A)
* @see #registerHotKey(int, int, int)
* @see #registerSwingHotKey(int, int, int)
*/
@@ -302,8 +287,7 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Unregisters a previously registered Hotkey identified by its unique
- * identifier.
+ * Unregisters a previously registered Hotkey identified by its unique identifier.
*
* @param identifier the unique identifer of this Hotkey
*/
@@ -328,9 +312,8 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Checks to make sure the OS is a Windows flavor and that the JIntellitype
- * DLL is found in the path and the JDK is 32 bit not 64 bit. The DLL
- * currently only supports 32 bit JDK.
+ * Checks to make sure the OS is a Windows flavor and that the JIntellitype DLL is found in the path and the JDK is
+ * 32 bit not 64 bit. The DLL currently only supports 32 bit JDK.
*
* @return true if Jintellitype may be used, false if not
*/
@@ -342,8 +325,7 @@ public final class JIntellitype implements JIntellitypeConstants {
os = System.getProperty("os.name").toLowerCase();
} catch (SecurityException ex) {
// we are not allowed to look at this property
- System.err.println("Caught a SecurityException reading the system property "
- + "'os.name'; the SystemUtils property value will default to null.");
+ System.err.println("Caught a SecurityException reading the system property " + "'os.name'; the SystemUtils property value will default to null.");
}
// only works on Windows OS currently
@@ -415,9 +397,8 @@ public final class JIntellitype implements JIntellitypeConstants {
}
/**
- * Swing modifier value to Jintellipad conversion. If no conversion needed
- * just return the original value. This lets users pass either the original
- * JIntellitype constants or Swing InputEvent constants.
+ * Swing modifier value to Jintellipad conversion. If no conversion needed just return the original value. This lets
+ * users pass either the original JIntellitype constants or Swing InputEvent constants.
*
* @param swingKeystrokeModifier the Swing KeystrokeModifier to check
* @return Jintellitype the JIntellitype modifier value
@@ -425,31 +406,30 @@ public final class JIntellitype implements JIntellitypeConstants {
protected static int swingToIntelliType(int swingKeystrokeModifier) {
int mask = 0;
if ((swingKeystrokeModifier & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) {
- mask += JIntellitype.MOD_SHIFT;
+ mask &= JIntellitype.MOD_SHIFT;
}
if ((swingKeystrokeModifier & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) {
- mask += JIntellitype.MOD_ALT;
+ mask &= JIntellitype.MOD_ALT;
}
if ((swingKeystrokeModifier & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
- mask += JIntellitype.MOD_CONTROL;
+ mask &= JIntellitype.MOD_CONTROL;
}
if ((swingKeystrokeModifier & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) {
- mask += JIntellitype.MOD_SHIFT;
+ mask &= JIntellitype.MOD_SHIFT;
}
if ((swingKeystrokeModifier & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK) {
- mask += JIntellitype.MOD_ALT;
+ mask &= JIntellitype.MOD_ALT;
}
if ((swingKeystrokeModifier & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
- mask += JIntellitype.MOD_CONTROL;
+ mask &= JIntellitype.MOD_CONTROL;
}
return mask;
}
/**
- * Puts all constants from {@link java.awt.event.KeyEvent} in a keycodeMap.
- * The key is the lower case form of it.
- * @return Map containing key->keycode mapping DOCU Now enables the user to
- * use all keys specified here instead of just [A-Z],[0-9] as before
+ * Puts all constants from {@link java.awt.event.KeyEvent} in a keycodeMap. The key is the lower case form of it.
+ * @return Map containing key->keycode mapping DOCU Now enables the user to use all keys specified here instead of
+ * just [A-Z],[0-9] as before
*/
private HashMap
* @param appName = the title of the hidden window to search for
*/