I have a Java program I wrote for my kids that allows them to paint a circle on a JPanel with the left mouse button, and then remove the circle by clicking with the right mouse button within the circle they created. Here is the code for the MouseListener:
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
switch (e.getButton()) {
case MouseEvent.BUTTON1:
addCircle(e.getPoint());
break;
case MouseEvent.BUTTON2:
// this does nothing
break;
case MouseEvent.BUTTON3:
removeCircle(e.getPoint());
break;
default:
// no default action
}
}
});
The program works fine with a regular mouse, but when using the MacBook multi-touch pad, the four finger swipe throws a JavaNativeException:
java[15233:507] Lookup: Unhandled exception 'JavaNativeException' caught in __57+[LULookupDefinitionModule _focusTermUsingQueue:handler:]_block_invoke
I tried wrapping in the generic Exception, but the JavaNativeException is still getting through.
Is this something that can be resolved without a third-party multi-touch library? It doesn't terminate the program, so my kids don't care. It's more of an academic question for me.