2016-05-19 16 views
1

removeCommand和removeAllCommand不起作用。如果我把它放在一個按鈕動作監聽器removeCommand(command)工作,但removeAllcommand()不工作? 這是一個錯誤?請檢查一下。三江源removeCommand不適用於工具欄命令 - codenameone

Command d = new Command("back") { 

     @Override 
     public void actionPerformed(ActionEvent evt) { 
     } 
}; 
f.setBackCommand(d); 
f.getToolbar().addCommandToLeftBar(d); 
//Either of these two doesnt remove above back command... 
f.removeAllCommands(); 
f.removeCommand(d); 

如果我把它放在行動聽衆,他們中的一個工作

Button add = new Button("remove"); 
    add.addActionListener((e) -> { 
     f.removeCommand(d);// it removes back command 
     f.removeAllCommands(); // it doesnt work 
}); 

回答

1

嘗試重新驗證表單

Button add = new Button("remove"); 
add.addActionListener((e) -> { 
      f.removeAllCommands(); 
      f.revalidate(); 
});