2017-03-16 1 views
0

J'ai un problème avec JavaFX et FXML. J'ai un simple fichier FXML structuré de cette manière:La vidéo dépasse la taille de la fenêtre - JavaFX et FXML

<?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> 

Le contrôleur se charge 2 vidéos et de les montrer dans les 2 AnchorPanes par rapport à l'intérieur du SPLITVIEW, comme le montre l'image suivante: ClickMe

La vidéo dépasse les limites de largeur du Parent AnchorPane, comment puis-je les définir correctement? Merci à tous.

Répondre

0

J'ai résolu ce problème avec la ligne suivante de code dans la classe contrôleur:

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

La gauche (même pour la droite) largeur Mediaview a été monté sur sa première largeur de parent (AnchorPaneL/AnchorPaneR).