remove命令不适用于工具栏命令 - codenameone

时间:2016-05-19 04:34:33

标签: codenameone

removeCommand和removeAllCommand不起作用。如果我把它放在一个按钮动作监听器removeCommand(命令)工作,但removeAllcommand()不起作用? 这是一个错误吗?请检查一下。三江源

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 个答案:

答案 0 :(得分:1)

尝试重新验证表单

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