【发布时间】:2021-06-10 12:46:56
【问题描述】:
我正在尝试制作一个通过舞台打开的模态窗口。这是代码:
Stage stage = new Stage();
Parent root = fxmlLoader.load();
stage.setScene(new Scene(root));
stage.setTitle("Stuff");
stage.initModality(Modality.WINDOW_MODAL);
stage.show();
但没有实际成功,尽管我能够单击底层窗口。 有什么我做错了吗?
编辑: 我早些时候查看了 Oracle 网站上的文档,但可以找到解决方案,因为显示的窗口的行为与模态窗口的预期并不接近。 我在这个项目中使用的 JDK 是 1.8.0_40
编辑 2: 根据ItachiUchiha的要求,句柄内的代码
Boolean confirmacion = MessageUtil.ventanaConfirmacion(RecursosUtil.creaTextoProperties("confNoRealizar"));
if (confirmacion) {
try {
TbInspeccion inspeccionSeleccionada = (TbInspeccion) getTableRow().getItem();
URL location = cargaURLFXML(OBSERVACIONESFXML);
FXMLLoader fxmlLoader = cargaFXML(location);
stage = new Stage();
Parent root = fxmlLoader.load();
stage.setScene(new Scene(root));
stage.setTitle("Observaciones");
ObservacionesController controller = (ObservacionesController) fxmlLoader.getController();
controller.setStage(stage);
controller.setInspeccion(inspeccionSeleccionada);
controller.setProvider(provider);
controller.setTablaPrincipal(tablaPrincipal);
stage.initModality(Modality.APPLICATION_MODAL);
stage.show();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
感谢您的时间和帮助。
【问题讨论】: