Java Reference
In-Depth Information
void
mouseReleased(MouseEvent e);
//This method executes when a mouse button is released
//on a component.
}
public class
MouseAdapter
implements
MouseListener
{
void
mouseClicked(MouseEvent e)
{
}
void
mouseEntered(MouseEvent e)
{
}
void
mouseExited(MouseEvent e)
{
}
void
mousePressed(MouseEvent e)
{
}
void
mouseReleased(MouseEvent e)
{
}
}
To register a
MouseListener
object to a GUI component, you use the method
addMouseListener
. The
MouseListener
object being registered is passed as a para-
meter to the method
addMouseListener
.
In addition to the GUI components with which you have worked, Chapter 12 introduces
other GUI components such as check boxes, option buttons, menu items, and lists. These
GUI components also generate events. Table 11-13 summarizes the various events
generated by GUI components. It also shows the GUI component, the listener interface,
and the name of the method of the interface to handle the event.
TABLE 11-13
Events Generated by a GUI Component, the Listener Interface, and the
Name of the Method of the Interface to Handle the Event
GUI Component
Event Generated
Listener Interface
Listener Method
actionPerformed
JButtton
ActionEvent
ActionListener
JCheckBox
ItemEvent
ItemListener
itemStateChanged
JCheckboxMenuItem
ItemEvent
ItemListener
itemStateChanged
JChoice
ItemEvent
ItemListener
itemStateChanged
JComponent
ComponentEvent
ComponentListener
componentHidden
JComponent
ComponentEvent
ComponentListener
componentMoved
Search WWH ::
Custom Search