so i have this anchorpane where i wish to add a mouse listner for the Secondary mouse key ive tried the following but i keep getting an error anyone know what the problem is?
mainDisplayPanel.addEventHandler(MouseButton.SECONDARY, new EventHandler<MouseButton>() {
@Override
public void handle(MouseButton event) {
System.out.Println("Works");
}
});
for the record i have also tried this:
mainDisplayPanel.addEventHandler(MouseButton.SECONDARY, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
System.out.println("WOrks");
}
});
Stack trace:
Bound mismatch: The generic method addEventHandler(EventType,
EventHandler) of type Node is not applicable for the
arguments (MouseButton, new EventHandler(){}). The
inferred type MouseButton&Event is not a valid substitute for the
bounded parameter
And the other:
Bound mismatch: The type MouseButton is not a valid substitute for the bounded parameter of the type EventHandler
There is no
EventTypebased onMouseButton.SECONDARY. You need to check theMouseEventitself: