scalafx - ScalaFX如何关闭二级
问题描述
如何关闭用作辅助窗口的二级阶段?所以我有一个primaryStage用作UI平台,偶尔我需要打开一个非常简单的辅助窗口,但是用一种方法关闭它还不清楚。
以下是第二阶段的参与方式:
val ivbox = new VBox(children = new Label("Create New Album"))
val stackpane = new StackPane()
sp.children = Seq(ivbox)
val secondstage = new Stage() {
title = "second stage"
scene = new Scene(stackpane, 450, 150) {
stylesheets += getClass.getResource("uistyle.css").toExternalForm
}
x = myproto.stage.x.value + 200 // position in relation to primaryStage / scene
y = myproto.stage.y.value + 100 //
}
在 JavaFX 中,我发现了这个片段:
private void closeButtonAction(){
Stage stage = (Stage) closeButton.getScene().getWindow();
stage.close();
}
不清楚如何在 ScalaFx 中获得?
解决方案
ScalaFX 没有区别。您使用close()
. ScalaFX 中的代码完全相同:
stage.close()
推荐阅读
- mongodb - 在 mongoDB 中自我加入
- vba - 在发送电子邮件之前禁用“规则”,然后在发送电子邮件后重新启用规则
- sql-server - 如何将行计数值从 toracleRow 组件传播到 talend 中的 tJava 组件?
- apache-spark - Spark 组中的超参数调整
- angular - Spartacus Loader Meta Reducer - 产品搜索
- reactjs - 为什么这个 ReactJS 导入结构不起作用?
- typescript - 检查类型保护与联合类型并返回与检测到的类型相反的类型的函数
- azure - .NET Core:将 Azure 存储 Blob 读入内存流会在 HttpBaseStream 中引发 NotSupportedException
- reactjs - 在启动时更改功能标志值后如何在反应应用程序中反映更新的数据
- python - 如何在python中的plotly express中在堆积条形图的顶部添加线图