private Parent replaceSceneContent(String fxml, double width, double height) throws Exception {
Parent page = (Parent) FXMLLoader.load(AppOtica_v2.class.getResource(fxml), null, new JavaFXBuilderFactory());
Scene scene = stage.getScene();
if (scene == null) {
scene = new Scene(page, width, height);
scene.getStylesheets().add(AppOtica_v2.class.getResource("estilo.css").toExternalForm());
stage.setScene(scene);
} else {
page.resize(width, height);
stage.getScene().setRoot(page);
}
page.resize(width, height);
stage.sizeToScene();
return page;
}
public void goToLogin() {
// Tela de Login
try {
replaceSceneContent("/view/login.fxml", 800, 600);
stage.setMinWidth(800);
stage.setMinHeight(600);
} catch (Exception ex) {
Logger.getLogger(AppOtica_v2.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void gotoPrincipal() {
// Tela Inicial
try {
replaceSceneContent("/view/principal_old.fxml", 1366, 768);
stage.setMinWidth(1024);
stage.setMinHeight(768);
stage.centerOnScreen();
//Fullscreen like mediaplayer
//stage.setFullScreen(true);
} catch (Exception ex) {
Logger.getLogger(AppOtica_v2.class.getName()).log(Level.SEVERE, null, ex);
}
}
No seu controller.login, se estiver correto vc chama outra tela.. (index, etc) implementando um método que utilize o replaceSceneContent.