gui - part 2

gui - part 2 - COP 4610L: Applications in the Enterprise...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 4610L: GUI Components Part 2 Page 1 Mark Llewellyn © COP 4610L: Applications in the Enterprise Fall 2006 GUI Components: Part 2 School of Computer Science University of Central Florida Instructor : Mark Llewellyn markl@cs.ucf.edu CSB 242, 823-2790 http://www.cs.ucf.edu/courses/cop4610/fall2006
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 4610L: GUI Components Part 2 Page 2 Mark Llewellyn © Mouse Event Handling The MouseListener and the MouseMotionListener event-listener interfaces are designed to handle mouse events . Mouse events can be trapped for any GUI component that derives from java.awt.Component . Package javax.swing.event contains interface MouseInputListener , which extends the two interfaces to create a single interface which contains all the methods of both interfaces. The MouseListener and the MouseMotionListener methods are called with the mouse interacts with a Component if the appropriate event-listener objects are registered for that Component.
Background image of page 2
COP 4610L: GUI Components Part 2 Page 3 Mark Llewellyn © Mouse Event Handling (cont.) Each of the mouse event-handling methods takes a MouseEvent object as its argument. A MouseEvent object contains information about the mouse event that occurred, including the x- and y- coordinates of the location where the event occurred. These coordinates are measured form the upper-left corner of the GUI component on which the event occurred. The x- coordinates begin a 0 and increase from left to right. The y- coordinates begin an 0 and increase from top to bottom. In addition, the methods and constants of class InputEvent (MouseEvent’s superclass) enable an application to determine which mouse button was clicked.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 4610L: GUI Components Part 2 Page 4 Mark Llewellyn © MouseListener and MouseMotionListener Interface Methods Methods of Interface MouseListener public void mousePressed(MouseEvent event) called when a mouse button is pressed while the mouse cursor is on a component. public void mouseClicked(MouseEvent event) called when a mouse button is pressed and released while the mouse cursor remains stationary on a component. This event is always preceded by a call to mousePressed . public void mouseReleased(MouseEvent event) called when a mouse button is released after being pressed. This event is always preceded by a call to mousePressed and one or more calls to mouseDragged . public void mouseEnetered(MouseEvent event) called when the mouse cursor enters the bounds of a component. public void mouseExited(MouseEvent event) called when the mouse cursor leaves the bounds of a component.
Background image of page 4
COP 4610L: GUI Components Part 2 Page 5 Mark Llewellyn © MouseListener and MouseMotionListener Interface Methods Methods of Interface MouseMotionListener public void mouseDragged(MouseEvent event) called when the mouse button is pressed while the mouse cursor is on a component and the mouse is moved while the mouse button remains pressed. This event is always preceded by a call to mousePressed . All drag events are sent to the component on which the user began to drag the mouse.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 59

gui - part 2 - COP 4610L: Applications in the Enterprise...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online