in the method mouseClicked (MouseEvent e) can anyone explain to me where that instance (e) initialized ?
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1)
System.out.println("Left button clicked!");
else if (e.getButton() == MouseEvent.BUTTON3)
System.out.println("Right button clicked!");
}
Is the System initialized ? And where ?
After you register a
MouseListeneron a component by callingaddMouseListener, that component will call the appropriate method on eachMouseListenerattached to it whenever aMouseEventoccurs, passing theMouseEventas the first argument.See also the
MouseListenerdocumentation: