Mouse Event Class Assignment Help

Assignment Help: >> Controls and Events - Mouse Event Class

Mouse Event Class:

There are various kinds of mouse events. The MouseEvent class declares the subsequent integer contents which can be used to recognize them:

MOUSE_CLICKED                          A user clicked the mouse

MOUSE_DRAGGED                      A user dragged the mouse

MOUSE_ENTERED                        The mouse entered a component

MOUSE_EXITED                             The mouse exited from a component.

MOUSE_MOVED                           The mouse moved.

MOUSE_PRESSED                         The mouse was pressed.

MOUSE_RELEASED                      The mouse was released.

Mouse Event is a subclass of InputEvent and has this constructor: MouseEvent(Component src,int type, long, when, int modifiers, int x, int y, int clicks boolean triggersPopup )

Above src is a reference to the competent which produced the event. The type of the event is specified through type.  A system time at that the mouse event occurred is passed in when.   The modifiers argument denotes that modifiers were pressed when a mouse event occurred.  A coordinated of the mouse are passed in x and y. A click count is passed in clicks. The triggersPopup flag denotes if this event causes a pop-up menu to appear on this platform.

The most general used methods in this class are getX ( ) and get Y ( ).   These return the X and y coordinates of the mouse when the event occurred.  Their forms are display here:

Int get X ( ) Int get Y ( )

In the other words, you can use the getPoint ( ) method to acquire the coordinated of the mouse. It is display here:

Point getPoint ( )

It returns a Point object which contains the X,Y coordinated in its integer members. X and y. The translatePoint( ) method modifies the location of the event .  Its form is display here:

Void translatePoint int x,int y)

Above the arguments x and y are added to the coordinated of the event.

The getClikCount( ) method acquire the number of mouse clicks for this event.  Its signature is display here:

Int getClickCount ( )

The is PopupTrigger( ) methods tests if this event causes a pop-up menu to appear on this platform. Its form is display here:

Bollean is PopupTrigger ( ).

The package java.awt.event defines several types of events that are generated by various user interface elements. The Most important event class are given in the below table.

Table . Main Event Classes in java.awt.event

Event Class                           Description

ActionEvent                          Produced when a button is pressed, a list item is Double-clicked, or a menu item is chosen.

AdjustmentEvent                Produced whenever a scroll bar is manipulated.

ComponentEvent                Produced when a component is hidden, moved, resized, o or becomes visible.

ContainerEvent                   Produced when a component is added to or removed from a container.

FocusEvent                           Produced when a component gains or loses keyboard focus.

InputEvent                           Abstract super class for all component input event classes

ItemEvent                          Produced when a checkbox or list item is clicked; also occurs when a choice selection is made or a checkable menu item is selected or deselected.

KeyEvent                              Produced when input is received from the keyboard.

MouseEvent                         Produced when the mouse is dragged, moved, clicked, pressed, or released; also generated when the mouse enters or exits a component.

TextEvent                              Produced when the value of a text area or text area or text field is changed.

WindowEvent                 Produced when a window is acivated, closed, deacivated, deiconified, iconified, opened, or quit.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd