I am creating an application in which i need to play video as shown below.

The red boundary represents an AnchorPane. There is MediaView in AnchorPane.
All i want is to make the MediaView (or the video) grow and shrink as i move the divider of split Pane. The code which i have written makes the video grow but when i move the divider of split pane back, the video does not shrink. Rather the video frame is cropped from the sides.
How to bind the dimensions of mediaView to its parent component? OR Whats wrong with my code ?
following is my code ...
public void start(Stage primaryStage) {
SplitPane video_text_SplitPane = new SplitPane();
Label label2 = new Label("abdsanjasj");
AnchorPane video_AnchorPane = new AnchorPane();
video_AnchorPane.setBorder(new Border(new BorderStroke(Color.RED,
BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
AnchorPane anchorPane2 = new AnchorPane();
AnchorPane.setBottomAnchor(label2, 0.0);
AnchorPane.setTopAnchor(label2, 0.0);
AnchorPane.setLeftAnchor(label2, 0.0);
AnchorPane.setRightAnchor(label2, 0.0);
anchorPane2.getChildren().add(label2);
// ---- CODE FOR PLAYING VIDEO ---
MediaView mediaView = new MediaView();
Media media = new Media("file:/E:/video.mp4");
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaView.setMediaPlayer(mediaPlayer);
mediaPlayer.setAutoPlay(true);
// mediaView.autosize();
// DoubleProperty width = mediaView.fitWidthProperty();
// DoubleProperty height = mediaView.fitHeightProperty();
// width.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width"));
// height.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height"));
video_AnchorPane.getChildren().add(mediaView);
video_text_SplitPane.getItems().add(video_AnchorPane);
AnchorPane.setBottomAnchor(video_AnchorPane, 0.0);
AnchorPane.setTopAnchor(video_AnchorPane, 0.0);
AnchorPane.setLeftAnchor(video_AnchorPane, 0.0);
AnchorPane.setRightAnchor(video_AnchorPane, 0.0);
mediaView.setPreserveRatio(true);
video_text_SplitPane.getItems().add(anchorPane2);
// ---- CODE FOR BINDING MEDIA VIEW DIMENSIONS TO ITS PARENT CONTAINER---
mediaView.fitWidthProperty().bind(video_AnchorPane.widthProperty());
mediaView.fitHeightProperty().bind(video_AnchorPane.heightProperty());
BorderPane video_textArea = new BorderPane();
video_textArea.setTop(rangeSliderAnchorPane);
video_textArea.setBottom(videoControlAnchorPane);
video_textArea.setCenter(video_text_SplitPane);=
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.HORIZONTAL);
splitPane.getItems().add(tree);
splitPane.getItems().add(video_textArea);
BorderPane layout = new BorderPane();
layout.setTop(menuBar);
layout.setCenter(splitPane);
layout.setBottom(new StatusBar());
Scene scene = new Scene(layout, 1920, 990);
primaryStage.setTitle("Subtitles Generator");
primaryStage.setScene(scene);
primaryStage.show();
}
Is this the what you are trying to achieve ?