Is there any reason why in LWUIT a Button can have its own ActionListener (via button.addActionListener) while a Command does not?
Is the only way to have a listener for a specific command is to add an ActionListener to a form and check the listener for which Command the event came from like below?
public void startApp() {
Display.init(this);
f = new Form("Mixed Record");
exit = new Command("Exit");
start = new Command("Start");
Button button = new Button("Button");
f.addCommand(exit);
f.addCommand(start);
f.addCommand(delete);
f.addComponent(button);
f.addCommandListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (ae.getCommand().equals(exit)) {
//Do Exit command code
} else if (ae.getCommand().equals(start)) {
//Do Start command code
}
}
});
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
//Do button code
}
});
f.show();
}