2011-02-05 207 views
1

我有一個javafx應用程序,我能夠產生另一個窗口,但我似乎無法找到一種方法來關閉我開始的窗口。我用這個來加載第二個窗口javafx關閉窗口

var design = Launcher {}; 

       javafx.stage.Stage 
       { 
        title: "Launcher" 
        scene: design.getDesignScene() 
       } 

回答

2

stage.close(),但您需要一個引用原始舞臺的變量。

+0

感謝,當我身邊試着出來我會相應地紀念這個答案。 – 2011-02-17 21:42:57

0

它爲我工作的方式:

  1. 我有,我instante我想看到第一窗口的Main.fx。 ex:

    var mainWind:MainWindow = MainWindow {};

  2. 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; 
    

    } }

  3. 在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{ }; 
        } 
    

    }

尤利亞