OK, I think I understand now: in MouseAdapter
class documentation it is said that "Create a listener object using the extended class and then register it with a component using the component's addMouseListener
, addMouseMotionListener
, addMouseWheelListener
methods". So now it looks like:
private class MouseListeners extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
//This method is being used, working fine
}
@Override
public void mouseDragged(MouseEvent e) {
//This method is being used, working fine
}
}
and then:
MouseListeners listeners = new MouseListeners();
addMouseListener(listeners);
addMouseMotionListener(listeners);
Now everything is OK.