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.
// 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!
Learn more about our help with Assignments:
JavaJSPJSF