2016-05-10 9 views
0

MediaViewGridPaneの内側に追加した後。すべてが期待どおりに動作しています。GridPaneでサイズ変更の問題が発生するのはなぜですか?

ただし、ウィンドウサイズを変更すると、MediaViewのサイズが変更されません。

ウィンドウを最大化した後、MediaViewが大きくなっていますが、それでも問題はありませんが、ウィンドウ復元を実行すると、MediaViewは小さくなりません。

現在のコード:

import java.io.File; 
import javafx.application.Application; 
import javafx.beans.binding.Bindings; 
import javafx.beans.property.DoubleProperty; 
import javafx.geometry.Insets; 
import javafx.scene.Scene; 
import javafx.scene.layout.ColumnConstraints; 
import javafx.scene.layout.GridPane; 
import javafx.scene.layout.Priority; 
import javafx.scene.layout.StackPane; 
import javafx.scene.media.Media; 
import javafx.scene.media.MediaPlayer; 
import javafx.scene.media.MediaView; 
import javafx.scene.paint.Color; 
import javafx.stage.Stage; 

public class MWindow extends Application { 
    @Override 
    public void start(Stage primaryStage) { 

     GridPane GB = new GridPane(); 
     GB.setHgap(10); 
     GB.setVgap(10); 
     GB.setPadding(new Insets(0, 10, 0, 10)); 
     ColumnConstraints col1 = new ColumnConstraints(); 
     col1.setPercentWidth(50); 

     ColumnConstraints col2 = new ColumnConstraints(); 
     col2.setHgrow(Priority.ALWAYS); 

     GB.setStyle("-fx-border: 2px solid; -fx-border-color: red;"); 

     GB.getColumnConstraints().addAll(col1, col2); 

     StackPane stack = new StackPane(); 
     StackPane stack1 = new StackPane(); 

     File f = new File("C:\\Users\\anaskar\\Desktop\\bisquad\\UserManual\\Demo.mp4"); 

     Media m = new Media(f.toURI().toString()); 
     MediaPlayer mp = new MediaPlayer(m); 
     MediaView mv = new MediaView(mp); 

     DoubleProperty width = mv.fitWidthProperty(); 
     DoubleProperty height = mv.fitHeightProperty(); 

     width.bind(Bindings.selectDouble(mv.parentProperty(), "width")); 
     height.bind(Bindings.selectDouble(mv.sceneProperty(), "height")); 

     mv.setPreserveRatio(true); 

     Media m1 = new Media(f.toURI().toString()); 
     MediaPlayer mp1 = new MediaPlayer(m1); 
     MediaView mv1 = new MediaView(mp1); 

     DoubleProperty width1 = mv1.fitWidthProperty(); 
     DoubleProperty height1 = mv1.fitHeightProperty(); 

     width1.bind(Bindings.selectDouble(mv1.parentProperty(), "width")); 
     height1.bind(Bindings.selectDouble(mv1.sceneProperty(), "height")); 

     stack.getChildren().add(mv); 
     stack1.getChildren().add(mv1); 

     Scene scene = new Scene(GB, 960, 540); 
     scene.setFill(Color.BLACK); 

     GB.add(stack, 0, 0, 1, 1); 
     GB.add(stack1, 1, 0, 1, 1); 

     primaryStage.setScene(scene); 
     primaryStage.setTitle("Full Screen Video Player"); 
     primaryStage.show(); 

     mp.play(); 
     mp1.play(); 

    } 

    public static void main(String[] args) { 
     launch(args); 
    } 
} 

答えて

0

あなたはMediaView

StackPane stack = new StackPane(); 
    stack.setMinSize(50, 50); 
    StackPane stack1 = new StackPane(); 
    stack1.setMinSize(50, 50); 
+0

どうもありがとうを含むStackPaneの最小サイズを設定する必要があります。その働く.. :) – Arijit

関連する問題