Charm 4.0.1两次调用时对话NPE

时间:2016-11-01 16:19:22

标签: gluon gluon-mobile

在Charm 3.0.0上,可以实例化一次Dialog并多次调用showAndWait。在Charm 4.0.1上调用dialog.showAndWait()两次会导致NPE。因此,每当我们想要显示对话框时,我们是否必须重新初始化对话框?

public class MyApp extends MobileApplication {

    private Dialog<ButtonType> dialog;

    @Override
    public void init() {

        addViewFactory(HOME_VIEW, () ->
        {
            initDialog();

            Button button = new Button("Show dialog");
            button.setOnAction(event -> dialog.showAndWait());

            return new View(button);
        });

    }

    private void initDialog() {
        dialog = new Dialog<>();
        dialog.setTitle(new Label("This is a regular dialog"));
        dialog.setContent(new Label("Just a regular dialog, plain and simple"));

        Button okButton = new Button("OK");
        okButton.setOnAction(e ->
        {
            dialog.hide();
        });

        dialog.getButtons().add(okButton);
    }
}    

0 个答案:

没有答案