Skip to content
Emmanuel Chebbi edited this page Nov 13, 2017 · 7 revisions

Launch a simple application

The heart of the framework is the class Play. Its usage is pretty close to the standard JavaFX's API ; here is a sample of a simple application :

public class Launcher extends Application {
	
  @Override
  public void start(Stage primaryStage) throws IOException {	
    // Initialize the play
    Play play = new Play(primaryStage);

    // Prepare a new scene and call it "firstView". 
    // It is semantically equal to FXMLLoader.load
    play.prepare("firstView", MyController.class.getResource("my.fxml"));

    // Put the scene "firstView" on the stage. It is semantically equal to stage.setScene
    play.setScene("firstView");

    // Finally, let the show begin ! It is semantically equal to stage.show
    play.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

Go to another scene

Just like with standard JavaFX's API, the method setScene can be used to display a new scene :

play.setScene("secondView");

The scene "secondView" must have been loaded previously by PlayFX :

play.prepare("secondView", SecondViewController.class.getResource("secondView.fxml"));