// setView is called before load
public void setView(Displayable v) {
this.view = (EnterNameView) v;
view.addCommand(new ActionCommand("Say hello",Command.SCREEN, 1){
public Navigation execute(Displayable d) throws Exception {
return new Navigation("say-hello",view.getName());
}
});
/* Please note that the command above can't be writter as
* view.addCommand(new NavigationCommand(
* new Navigation("say-hello", view.getName()), "Say hello", Command.SCREEN, 1));
* because view.getName() has to be evaluated each time the command is executed
*/
view.addCommand(new ActionCommand("Quit",Command.SCREEN, 9){
public Navigation execute(Displayable d) throws Exception {
controler.getMidlet().notifyDestroyed();
return null;
}
});
view.addCommand(new NavigationCommand(new Navigation("say-hello", null),
"Slow load", Command.SCREEN, 2));
view.addCommand(new ActionCommand("Slow action", Command.SCREEN, 3){
public Navigation execute(Displayable d) throws Exception {
String name = view.getName();
controler.progressListner.setMaxValue(name.length());
for(int i=0;i<name.length();++i) {
//slow operation: