Answer to Question #63451 in Java | JSP | JSF for Ariel Martinez

Question #63451
What is the difference between ActionListener and ItemListener?

Just write the most important thing to answer that question in a small paragraph and shows examples in code.
1
Expert's answer
2016-11-22T12:56:11-0500
// we use anonymous ActionListener to doSomething() when someone click button
JButton b = new JButton();
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doSomething();
}
});
// we use ItemListener to doSomething() when this checkbox selected or
deselected
Checkbox cb = new Checkbox();
cb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
doSomething();
}
});

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS