hi all
im janaka priyadarsahana
i want to write actions for buttons.
i have 4 buttons and when they click i want to do four seperate things
for this i have several options
create new class by implimenting Action listener interface and using an object of that class, can handle the actions.
use one class by implimenting Action listener interface and create all buttons in that class and then add actions for the buttons
create 4 seperate instence of action listener interface and do required things.
this is as follow
public class MyClass{
JButton myButton1 = new JButton();
ActionListener action1 = new ActionListener() {
public void actionPerformed(ActionEvent e) {
//do required
}
}
myButton1.addActionListener(action1)
}
i want to know what is the best method for my requirement
please anyone can help me..
thank you
janaka