You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
64 lines
1.9 KiB
package seng302;
|
|
|
|
import javafx.application.Application;
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.scene.Parent;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.layout.BorderPane;
|
|
import javafx.stage.Stage;
|
|
import seng302.Controllers.Controller;
|
|
import seng302.Controllers.MainController;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
public class App extends Application
|
|
{
|
|
Stage primaryStage;
|
|
BorderPane mainContainer;
|
|
Scene mainScene;
|
|
|
|
public static void main( String[] args )
|
|
{
|
|
launch(args);
|
|
}
|
|
|
|
@Override
|
|
public void start(Stage primaryStage) throws Exception {
|
|
this.primaryStage = primaryStage;
|
|
|
|
//load the first container
|
|
try {
|
|
FXMLLoader loader = new FXMLLoader();
|
|
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//mainpane.fxml");
|
|
mainContainer = (BorderPane) loader.load(in);
|
|
mainScene = new Scene(mainContainer, 800, 600);
|
|
primaryStage.setScene(mainScene);
|
|
primaryStage.sizeToScene();
|
|
MainController mainController = (MainController) loader.getController();
|
|
mainController.setParent(this);
|
|
in.close();
|
|
//add the center
|
|
loadPane("racepane.fxml");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
primaryStage.show();
|
|
}
|
|
|
|
public void loadPane(String fxmlName) throws Exception{
|
|
FXMLLoader loader = new FXMLLoader();
|
|
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//"+fxmlName);
|
|
Parent page;
|
|
try {
|
|
page = (Parent) loader.load(in);
|
|
} finally {
|
|
in.close();
|
|
}
|
|
mainContainer.getChildren().remove(mainContainer.getCenter());
|
|
mainContainer.setCenter(page);
|
|
Controller controller = (Controller) loader.getController();
|
|
controller.setParent(this);
|
|
}
|
|
}
|