Adv Java Lec-7 Event Handling.c8e5e28
Adv Java Lec-7 Event Handling.c8e5e28
Course: Advanced Java, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Advanced Java, Prepared By: Atul Kabra, 9422279260
ActionEvent:-
The ActionListener interface contains the one method that is called
when an ActionEvent occurs.
For an object to listen for action events, it is necessary to call the
addActionListener() method with the class that implements the
ActionListener interface as the parameter.
The method addActionListener() is implemented by Button, List,
MenuItem, and TextField components.
Whenever the user clicks the button, the Button object creates an
ActionEvent object and calls listener.actionPerformed(event) passing
that event object.
The button calls the actionPerformed method whenever the user
clicks the button.
Course: Advanced Java, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Advanced Java, Prepared By: Atul Kabra, 9422279260
Course: Advanced Java, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Advanced Java, Prepared By: Atul Kabra, 9422279260
ButtonThisTest()
{
setSize(600,500);
setTitle("Info Planet - Button Test");
setLayout(new FlowLayout());
add(b);
b.addActionListener( this);
}
Course: Advanced Java, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Advanced Java, Prepared By: Atul Kabra, 9422279260
ButtonAnonymousTest()
{
setSize(600,500);
setTitle("Info Planet - Button Test");
setLayout(new FlowLayout());
add(b);
Course: Advanced Java, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260