http://code.makery.ch/java/javafx-2-tutorial-part5
Here is a good tutorial for doing that with a sample code example
Controller...
//Application class type variable
public MainApp mainApp;
public Stage stage;
.........
.........
/**
* Is called by the main application to give a reference back to itself.
*
* @param mainApp
*/
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
}
.....
.........
@FXML
public void initialize(){
stage=mainApp.getStage();
}
Application class....
class MainApp extends Application{
Stage stage;
...
...
@Override
public void start(Stage stage) {
this.stage=stage;
FXMLLoader loader = new
FXMLLoader(MainApp.class.getResource("view/PersonOverview.fxml"));
PersonOverviewController controller = loader.getController();
controller.setMainApp(this);
}
...
,,
public getStage()
{
return this.stage;
}
}