What Is The Difference Between Mouse Clicked And Mouse Entered?

1

1 Answers

raaga Profile
raaga answered
These are the two events. The 'mouse clicked' is an even that works when a mouse button is clicked(pressed and released) whereas 'mouse entered' event works when the mouse enters a component or some specified area. Normally muoseClicked method is used for selecting or double clicking an icon. As mouse click is a combination of pressing and releasing the mouse button, mousePressed() and mouseReleased() methods are called before the event is dispatched to the MouseClicked() method.For 'mouse entered' event there is no need to click the mouse button it is invoked whenever it is within the component that is listening to it. Java provides us event listeners for event handling. Both 'mouse clicked' and 'mouse entered' events are handled by the 'MouseLisener' interface. Following is the general form of these two methods in Java.
void mouseClicked(MouseEvent me)
void mouseEntered(MouseEvent me)
In Java both these methods work by taking an argument of the type 'MouseEvent'. MouseEvent is the subclass of InputEvent class and it defines the following eight integer constants
MOUSE_CLICKED
MOUSE_DRAGGED
MOUSE_ENTERED
MOUSE_EXITED
MOUSE_MOVED
MOUSE_PRESSED
MOUSE_RELEASED
MOUSE_WHEEL
To use the mouseClicked and mouseEntered events MouseListener interface must be implemented.

Answer Question

Anonymous