frame = new JInternalFrame();
frame.setContentPane(this);
- if (Platform.isAMacAndNotJS())
- {
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 480);
- }
- else
- {
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 450);
- }
+ Desktop.addInternalFrame(frame,
+ MessageManager.getString("label.sequence_feature_settings"),
+ 600, Platform.isAMacAndNotJS() ? 480 : 450);
frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
frame.addInternalFrameListener(
public class Platform
{
- private static Boolean isNoJSMac = null, isNoJSWindows = null;
+ private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null, isWin = null;
private static Boolean isHeadless = null;
/**
+ * added to group mouse events into Windows and nonWindows (mac, unix, linux)
+ * @return
+ */
+ public static boolean isMac()
+ {
+ return (isMac == null ? (isMac = (System.getProperty("os.name").indexOf("Mac") >= 0)) : isMac);
+ }
+
+ /**
+ * added to group mouse events into Windows and nonWindows (mac, unix, linux)
+ * @return
+ */
+ public static boolean isWin()
+ {
+ return (isWin == null ? (isWin = (System.getProperty("os.name").indexOf("Win") >= 0)) : isWin);
+ }
+
+ /**
* sorry folks - Macs really are different
*
* BH: disabled for SwingJS -- will need to check key-press issues
*/
public static boolean isAMacAndNotJS()
{
- if (isNoJSMac == null)
- {
- isNoJSMac = /** @j2sNative false && */
- System.getProperty("os.name").indexOf("Mac") > -1;
- }
-
- return isNoJSMac.booleanValue();
-
+ return (isNoJSMac == null ? (isNoJSMac = /** @j2sNative false && */isMac()) : isNoJSMac);
}
- /**
+/**
* Check if we are on a Microsoft plaform...
*
* @return true if we have to cope with another platform variation
*/
public static boolean isWindowsAndNotJS()
{
- if (isNoJSWindows == null)
- {
- isNoJSWindows = /** @j2sNative false && */
- System.getProperty("os.name").indexOf("Win") > -1;
- }
- return isNoJSWindows.booleanValue();
- }
-
-// BH - preferred:
-//
-// /**
-// * @return true if this is a Mac
-// */
-// private static boolean isAMac()
-// {
-// if (isAMac == null)
-// {
-// isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
-// }
-//
-// return isAMac.booleanValue();
-//
-// }
-//
-// /**
-// * Check if we are on a Microsoft plaform...
-// *
-// * @return true if we have to cope with another platform variation
-// */
-// private static boolean isWindows()
-// {
-// if (isWindows == null)
-// {
-// isWindows = System.getProperty("os.name").indexOf("Win") > -1;
-// }
-// return isWindows.booleanValue();
-// }
-//
+ return (isNoJSWin == null ? (isNoJSWin = /** @j2sNative false && */isWin()) : isNoJSWin);
+ }
/**
*
*/
public static boolean isControlDown(MouseEvent e)
{
- boolean aMac = isAMacAndNotJS();
- return isControlDown(e, aMac);
+ return isControlDown(e, isMac());
}
/**
*/
protected static boolean isControlDown(MouseEvent e, boolean aMac)
{
- if (aMac)
- {
- /*
- * answer false for right mouse button
- */
- if (e.isPopupTrigger())
- {
- return false;
- }
- return (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
- & e.getModifiers()) != 0;
- // could we use e.isMetaDown() here?
+ if (!aMac) {
+ return e.isControlDown();
}
- return e.isControlDown();
+ // answer false for right mouse button
+ // shortcut key will be META for a Mac
+ return !e.isPopupTrigger()
+ && (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() & e.getModifiers()) != 0;
+ // could we use e.isMetaDown() here?
}
+ /**
+ * Windows (not Mac, Linux, or Unix) and right button
+ * to test for the right-mouse pressed event in Windows
+ * that would have opened a menu or a Mac.
+ *
+ * @param e
+ * @return
+ */
public static boolean isWinRightButton(MouseEvent e)
{
- return !isAMacAndNotJS() && SwingUtilities.isRightMouseButton(e);
- }
+ // was !isAMac(), but that is true also for Linux and Unix and JS,
+ return isWin() && SwingUtilities.isRightMouseButton(e);
+ }
+
+
+ /**
+ * Windows (not Mac, Linux, or Unix) and middle button -- for mouse wheeling
+ * without pressing the button.
+ *
+ * @param e
+ * @return
+ */
public static boolean isWinMiddleButton(MouseEvent e)
{
- return !isAMacAndNotJS() && SwingUtilities.isMiddleMouseButton(e);
+ // was !isAMac(), but that is true also for Linux and Unix and JS
+ return isWin() && SwingUtilities.isMiddleMouseButton(e);
}
}