javafx关闭窗口
问题描述:
我有一个javafx应用程序,我能够产生另一个窗口,但我似乎无法找到一种方法来关闭我开始的窗口。我用这个来加载第二个窗口javafx关闭窗口
var design = Launcher {};
javafx.stage.Stage
{
title: "Launcher"
scene: design.getDesignScene()
}
答
stage.close(),但您需要一个引用原始舞台的变量。
答
它为我工作的方式:
-
我有,我instante我想看到第一窗口的Main.fx。 ex:
var mainWind:MainWindow = MainWindow {};
-
MainWindow.fx将扩展CustomNode并覆盖create()方法。 在我的舞台 前的create()方法:
公共类主窗口扩展CustomNode {
...
VAR阶段:第一阶段;
超驰功能的create():节点{
var n:Node; stage = Stage { width: 300 height: 180 title: "Login" scene: Scene { content:[ userText, userTextBox, passwdText, passwdTextBox, btnsBox ] } } return n;
} }
-
在MainWindow.fx我与其中I关闭此阶段,并显示另一个的事件的按钮。 例如:
按钮{
text: "Login" font:Font{ name:"Arial" size: 12} layoutInfo:LayoutInfo { width: loginbtn_width } blocksMouse: false //close main window onMouseClicked: function(e:MouseEvent):Void { stage.close(); } //open the other window action: function(){ // the ConnectionSettings will also extend CustomNode and will have its own stage var conSetWind:ConnectionSettings = ConnectionSettings{ }; }
}
尤利亚
感谢,当我身边试着出来我会相应地纪念这个答案。 – 2011-02-17 21:42:57