68 329
Assignments Done
98,8%
Successfully Done
In November 2018

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.
Expert's answer
// 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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions