0
votes

i've a trouble with JavaFX and FXML. I've a simple FXML file structured in this way:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.media.MediaView?>

<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="480.0" minWidth="720.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mediaplayer.MediaPlayerControllerSplit">
   <center>
      <SplitPane dividerPositions="0.5" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" BorderPane.alignment="CENTER">
        <items>
          <AnchorPane fx:id="mediaPaneL" style="-fx-background-color: green;">
               <children>
                  <MediaView fx:id="mediaViewL" />
               </children>
            </AnchorPane>
          <AnchorPane fx:id="mediaPaneR" style="-fx-background-color: red;">
               <children>
                  <MediaView fx:id="mediaViewR" />
               </children>
            </AnchorPane>
        </items>
      </SplitPane>
   </center>
   <bottom>
      <ToolBar minHeight="-Infinity" minWidth="-Infinity" style="-fx-background-color: black;" BorderPane.alignment="BOTTOM_CENTER">
         <items>
            <Button mnemonicParsing="false" onAction="#openVideo" text="Openfile" />
            <Button mnemonicParsing="false" onAction="#playVideo" text="&gt;" />
            <Button mnemonicParsing="false" onAction="#pauseVideo" text="||" />
            <Button mnemonicParsing="false" onAction="#stopVideo" text="stop" />
            <Button mnemonicParsing="false" text="&lt;&lt;&lt;" />
            <Button mnemonicParsing="false" text="&lt;&lt;" />
            <Button mnemonicParsing="false" text="&gt;&gt;" />
            <Button mnemonicParsing="false" text="&gt;&gt;&gt;" />
            <Button mnemonicParsing="false" onAction="#exitVideo" text="EXIT" />
         </items>
      </ToolBar>
   </bottom>
</BorderPane>

The controller will load 2 videos and show them in the relative 2 AnchorPanes inside the SplitView, as shown in the following image: ClickMe

The video exceeds from width bounds of the Parent AnchorPane, how can i set them properly? Thanks all.

1

1 Answers

0
votes

I've solved this with the following line of codes in the Controller class:

mediaViewL.fitWidthProperty().bind(mediaPaneL.widthProperty());

The left (same for the right one) mediaView width has been fitted to his first Parent width (AnchorPaneL / AnchorPaneR).