MouseEvent Class
An event that indicates that a mouse action occurred in a component such as pressing a mouse button.
MouseEvent
When the user presses one of the buttons on a mouse, an object that belongs to a ____________ class is constructed
Event Source
component to which the user clicked
x and y coordinates
the point in the component where the click occurred
mouse-based
To work, the mouse event type should be registered by adding the appropriate __________ Event Listener to the component.
MouseListener
used for basic mouse-oriented events
MouseListener
happens when the mouse is clicked or released
MouseMotionListener
used for the motion-oriented events
MouseMotionListener
happens whenever the mouse is moved; frequent
public void mousePressed(MouseEvent evt)
method called when the user presses down a mouse button
public void mouseReleased(MouseEvent evt)
method called when the user releases a button
public void mouseClicked(MouseEvent evt)
method called if the user presses a mouse button and then releases it, without moving the mouse.
public void mouseClicked(MouseEvent evt)
The mousePressed, mouseReleased, and mouseClicked routines are all called in that order.
mousePressed
In most cases, you should define _______ instead of mouseClicked
public void mouseEntered(MouseEvent evt)
method called when the mouse cursor enters the component.
public void mouseExited(MouseEvent evt)
method called when the mouse cursor leaves the component.
object
Registering Mouse Events: create an ______ that implements the MouseListener interface
addMouseListener()
Registering Mouse Events: register the object to listen for events by calling a component's ____________ method.
public void mouseDragged(MouseEvent evt)
method called when the user moves the mouse while holding down a mouse button until the button is released
F
public void mouseDragged(MouseEvent evt) only works if the mouse position is within the bounds of the component
T or F
public void mouseMoved(MouseEvent evt)
method called when the user moves the mouse while no mouse button is down
MouseEvent
The _______ object in the parameter contains the x and y coordinates of the mouse's location
MouseMotionListener
Registering MouseMotion Events: create an object that implements the _____________ interface
addMouseMotionListener()
register the object to listen for events by calling a component's _____________________ method
MouseListener
In most cases, the listener object will also implement the ___________ interface so that it can respond to the other mouse events as well
Menu
is a list of buttons each of which have their own corresponding action when selected
Drop-Down
Types of Menu: usually associated with an application's menubar
Pop-Up
Types of Menu: associated with any container component (i.e., often accessed via right button click)
Cascaded
Types of Menu: pops up when another menu item is selected (i.e. a sub menu)
pull-down
Types of Menu: other term for drop-down menu
JMenuBar
An object at the top of the frame that contains "pull down" menus. There can be only one per frame.
names
Only the _____ of the pull down menus are displayed on the menubar.
JMenu
A menu that may contain menu items, separator lines, and other menus.
JMenuItems
menu items which the user can select from (like buttons)
JSeparators
separator lines to divide up the items into logical groupings
action
The user selects an option and an _____ is performed
JMenu
It is added to a JMenuBar object by specifying its name (or label) which will appear on the menubar
JMenuItem
A button on a menu. When the user selects the "button", the action associated with the menu item is performed
ImageIcons
__________ can be used on menus as well by assigning an icon to a menultem (just like JButtons)
JRadioButtonMenuItem
A menu item that is part of a group of menu items in which only one item in the group can be selected
JPopupMenu
A small window which pops up and displays a menu of choices
JPopupMenu
Used for the menu that appears when the user selects an item on the menu bar (similar to cascaded menu)
JPopupMenu
Also used for "pull-right" menus that appear when the user selects a menu item that activates it
JPopupMenu
can also be used anywhere else you want a menu to appear (e.g., when the user right-clicks in a specified area)
JFrame
A single JMenuBar is added to a __________
JMenus
Multiple ______ are added to the JMenuBar
JFrame
JPopupMenus are added to _______
setJMenuBar()
method used to set the JFrame's menubar to the instance of JMenuBar
.setMnemonic();
method used to set the keyboard accelerators (i.e., quick keys)
dialog box
a separate window that pops up in response to an event occurring in a window
dialog box
often used to obtain information from the user
Message Dialog
displays a message indicating information, errors, warnings etc
Confirmation Dialog
asks a question such as yes/no
Input Dialog
asks for some kind of input
Option Dialog
asks the user to select some option