从后退命令处理对话框

时间:2018-01-06 04:17:23

标签: codenameone

我有一个对话框,我想要从后面的命令处理。但它没有发生。为什么?

selectDialog = new Dialog();
selectDialog.showPacked(BorderLayout.CENTER, false);
selectDialog.setDisposeWhenPointerOutOfBounds(true);

//why doesn't following code dispose dialog box?
Command back = new Command("") {
    public void actionPerformed(ActionEvent ev) {
        if (selectDialog != null) {
            System.out.println("beck");
            selectDialog.dispose();
        }
    }
};
setBackCommand(back);

1 个答案:

答案 0 :(得分:0)

而不是:

setBackCommand(back);

使用:

selectDialog.setBackCommand(back);