I suppose what you need it's a controller.
First you have to add the following as attribute on the StackPane line of the FXML
fx:controller="the.package.ControllerName"
And a attribute on the ImageView with the Id:
fx:id="imageId"
Where of course the.package is the package of the Controller you are going to use.
To implement the controller create a new class with the name you want and extend StackPane and override the initialize method:
package the.package;
public class ControllerName extends StackPane{
@FXML
ImageView imageId;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
//You can add code here.
//With JavaFX2
widthProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
myImageView.setFitWidth(stage.getWidth());
}
});
//With JavaFX8 Using Lambdas
widthProperty().addListener((ov, t, t1) ->
myImageView.setFitWidth(getWidth()));
}
}
If this do not work you will need to create a new public method in the controller that resizes the ImageView. You can call this method from the stage listener that you have implemented.
Tell me if this is not what you where looking for.
P.S - I have a little project that uses this concepts here!