MouseWheelEventEx: don't warn on absent getScrollingDelta method

This commit is contained in:
Pavel Fatin
2017-01-19 13:44:47 +01:00
parent c2217d894a
commit 9b6faa61a1
2 changed files with 8 additions and 2 deletions
@@ -27,7 +27,7 @@ import java.awt.event.MouseWheelEvent;
* an <a href="https://github.com/JetBrains/jdk8u_jdk/commit/a3cb8807b148879e9c70a74a8a16c30a28991581">implementation</a> for Mac OS X).
*/
class MouseWheelEventEx {
private static final MethodInvocator ourGetScrollingDeltaMethod = new MethodInvocator(MouseWheelEvent.class, "getScrollingDelta");
private static final MethodInvocator ourGetScrollingDeltaMethod = new MethodInvocator(false, MouseWheelEvent.class, "getScrollingDelta");
/**
* Returns scrolling delta as an absolute value (if available).
@@ -26,6 +26,10 @@ public class MethodInvocator {
private Method myMethod;
public MethodInvocator(Class<?> aClass, String method, Class<?>... parameterTypes) {
this(true, aClass, method, parameterTypes);
}
public MethodInvocator(boolean warnIfAbsent, Class<?> aClass, String method, Class<?>... parameterTypes) {
try {
myMethod = aClass.getDeclaredMethod(method, parameterTypes);
@@ -34,7 +38,9 @@ public class MethodInvocator {
}
}
catch (NoSuchMethodException e) {
LOG.warn("Method not found: " + aClass.getName() + "." + method);
if (warnIfAbsent) {
LOG.warn("Method not found: " + aClass.getName() + "." + method);
}
}
}