Action Listener Flashcards

1
Q

Action Listener

A

Event handlers, what should be done when a user performs certain operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Action Event Examples

A

User clicks a button
Chooses a menu item
Presses Enter in a text field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write Action Listener Steps

A
Declare event handler class either implements ActionListener interface or extends class that implements ActionListener interface
Register instance of event handler class as a listener on component
Include code that reacts to the action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write Action Listener Code

A
public class MyClass implements ActionListener
{
someComponent.addActionListener(instanceOfMyClass);
public void actionPerformed(ActionEvent e)
{
//reaction code
}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

addActionListener method

A

Program registers object as action listener on button or event source

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ActionEvent argument

A

Single argument gives information about event and its source

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Action Listener Interface

actionPerformed(actionEvent)

A

Called just after the user performs an action

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Action Event Class
String getActionCommand()
A

Return string associated with this action

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Action Event Class
int getModifiers()
A

Returns integer represent modifier keys user was pressing on keyboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Action Event Class
Object getSource()
A

Returns obj that fired the event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly