Can only be implemented, but this jump method is not a specification I am not very clear
For example: Click Jfx2.java to create a button on the stage to jump to the stage created by Jfx3.java
The code is as follows:
Jfx2.java
Package review;
Import javafx.application.*;
Import javafx.scene.*;
Import javafx.stage.*;
Import javafx.scene.control.*;
Import javafx.scene.layout.*;
public class JFX2 extends application
{public
static void Main (string[] args)
{
launch (args);
}
@Override public
void Start (Stage Stage) throws Exception {Stackpane pane=new stackpane
();
Button Button=new button ("Open another Stage");
Button.setcursor (Cursor.hand);
Button.setonaction (e->{
Jfx3 open=new Jfx3 ();
Try
{
Open.start (new Stage ());
Stage.hide ();
}
catch (Exception E1)
{
e1.printstacktrace ();
}
});
Pane.getchildren (). Add (button);
Scene scene=new Scene (pane,300,200);
Stage.setscene (scene);
Stage.settitle ("Demo");
Stage.show ();
}
Jfx3.java
Package review;
Import javafx.application.*;
Import javafx.scene.*;
Import javafx.stage.*;
Import javafx.scene.control.*;
Import javafx.scene.layout.*;
public class Jfx3 extends application
{
@Override public
void Start (Stage Stage) throws Exception
{
Stackpane pane=new Stackpane ();
Label Lb=new label ("This is a new stage");
Lb.setcursor (Cursor.hand);
Pane.getchildren (). Add (lb);
Scene scene=new Scene (pane,300,200);
Stage.setscene (scene);
Stage.settitle ("Demo");
Stage.show ();
}
The key part is
Button.setonaction (e->{
Jfx3 open=new Jfx3 ();
Try
{
Open.start (new Stage ());
Stage.hide ();
}
catch (Exception E1)
{
e1.printstacktrace ();
}
});
Call the Start () method of Jfx3.java (to jump to the interface) to achieve the purpose of the Jump interface;
If you need to let the interface of the previous layer not appear, you can invoke the Hide () method to "hide" the previous layer of interface, in the Hide () method document, the explanation is: attempts to hide this Window by setting the visibility to false. It means "trying to hide this window by setting the visibility to false." But the direct "hide" is reasonable I also difficult to judge, welcome everybody to offer the suggestion.