How to set video stretch in to parent size in javafx
<p>I am trying to play a video using javaFx.I don't know how to fit the video in to the correct size of parent. When i click the maximize button of the window, video goes to the left corner of the view. How to make it responsive? some one please give me a good idea to make it possible. </p>

<pre><code> public class ServerController{

    @FXML
        private BorderPane mainlayout;

    public void loadVideo(){
            String workingDir = System.getProperty("user.dir");
            final File f = new File(workingDir,"/src/main/resources/video/video.mp4");
            final Media m = new Media(f.toURI().toString());
            final MediaPlayer player = new MediaPlayer(m);
            final MediaView view = new MediaView(player);
            final DoubleProperty width = view.fitWidthProperty();
            final DoubleProperty height = view.fitHeightProperty();
            width.bind(Bindings.selectDouble(view.sceneProperty(), "width"));
            height.bind(Bindings.selectDouble(view.sceneProperty(), "height"));
            view.setPreserveRatio(true);
            mainlayout.getChildren().add(view);;
            player.play();

            }
}
</code></pre>

<p>I will call "loadVideo()" method to set the video view. Rest of the codes are excluded for the purpose of brevity.   </p>

<p>fxml page</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;?import java.lang.*?&gt;
&lt;?import javafx.scene.layout.*?&gt;

&lt;BorderPane fx:id="mainlayout" minHeight="720.0" minWidth="1280.0" styleClass="welcome-border-pane1" stylesheets="@../css/fextile.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1"&gt;  
&lt;/BorderPane&gt;
</code></pre>