javafx Dialog无法关闭

// 生成二维码图片
                String qrCodeText = "https://example.com";

                DialogPane grid = new DialogPane();
                grid.setPadding(new Insets(5));

                VBox vBox = new VBox();
                vBox.setAlignment(Pos.CENTER);
                Image qrCodeImage = generateQRCodeImage(qrCodeText);
                ImageView customImage = new ImageView(qrCodeImage);

                Label label = new Label("12121");

                vBox.getChildren().addAll(customImage, label);
                grid.setContent(vBox);


                Dialog dlg = new Dialog<>();
                Window window = dlg.getDialogPane().getScene().getWindow();
                window.setOnCloseRequest(event1 -> window.hide());
                dlg.setDialogPane(grid);
                dlg.show();

java - javafx.scene.control.Dialog won't close on pressing "x" - Stack Overflow

你可能感兴趣的:(java,数据库,缓存)