git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
912ad6b
)
JAL-3446 separated out potential exceptions for simplified key mask operation
author
soares
<bsoares@dundee.ac.uk>
Fri, 12 Jun 2020 11:15:32 +0000
(12:15 +0100)
committer
soares
<bsoares@dundee.ac.uk>
Fri, 12 Jun 2020 11:15:32 +0000
(12:15 +0100)
src/jalview/util/Platform.java
patch
|
blob
|
history
diff --git
a/src/jalview/util/Platform.java
b/src/jalview/util/Platform.java
index
62f618a
..
bc21fa1
100644
(file)
--- a/
src/jalview/util/Platform.java
+++ b/
src/jalview/util/Platform.java
@@
-115,24
+115,45
@@
public class Platform
static
{
static
{
- if (!GraphicsEnvironment.isHeadless())
- {
+ // Using non-deprecated Extended key mask modifiers, but Java 8 has no
+ // getMenuShortcutKeyMaskEx method
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Method method = null;
try
{
try
{
-
- Toolkit tk = Toolkit.getDefaultToolkit();
- Method method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx");
- if (method == null)
+ method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx");
+ } catch (NoSuchMethodException e)
+ {
+ System.err.println(
+ "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask.");
+ }
+ if (method == null)
+ {
+ try
+ {
method = tk.getClass().getMethod("getMenuShortcutKeyMask");
method = tk.getClass().getMethod("getMenuShortcutKeyMask");
- SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0]));
- if (SHORTCUT_KEY_MASK <= 0xF)
+ } catch (NoSuchMethodException e)
{
{
- // shift this into the extended region (was Java 8)
- SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6;
+ System.err.println(
+ "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask.");
+ e.printStackTrace();
}
}
- } catch (Exception e)
+ }
+ if (method != null)
{
{
- e.printStackTrace();
+ try
+ {
+ method.setAccessible(true);
+ SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0]));
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (SHORTCUT_KEY_MASK <= 0xF)
+ {
+ // shift this into the extended region (was Java 8)
+ SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6;
}
}
}
}
}
}