Fixed event handling on the Java side