如果我想在JavaFX中调整ImageView的大小,使其只适合borderpane的整个左侧区域,而不调整到其他区域?

如果我想在JavaFX中调整ImageView的大小,使其只适合borderpane的整个左侧区域,而不调整到其他区域?,java,javafx,imageview,borderpane,Java,Javafx,Imageview,Borderpane,我想调整图像的大小,使其适合边框窗格的整个左侧区域,但我不了解边框窗格的不同区域。它们都有相同的尺寸吗?下面的代码我在左侧区域添加了一个窗格,但我真的不太了解根据添加到其中的节点的大小自动调整区域大小的方法。一些指向正确方向的指针会很好。此外,该控制器类用于添加在计时器上淡入淡出的图像幻灯片 public class Controller implements Initializable { @FXML public ImageView current; public ImageView n

我想调整图像的大小,使其适合边框窗格的整个左侧区域,但我不了解边框窗格的不同区域。它们都有相同的尺寸吗?下面的代码我在左侧区域添加了一个窗格,但我真的不太了解根据添加到其中的节点的大小自动调整区域大小的方法。一些指向正确方向的指针会很好。此外,该控制器类用于添加在计时器上淡入淡出的图像幻灯片

 public class Controller implements Initializable {
@FXML  public ImageView current;
public ImageView next;
@FXML public BorderPane borderPane;
@FXML public Button nextButton = new Button();
static int count = 0;
@FXML public Pane pane;
ArrayList<Image> imagesArrayList = new ArrayList<>();


@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    imagesArrayList.add(new Image("/sample/pictures/download.jpg"));
    imagesArrayList.add(new Image("/sample/pictures/images.jpg"));
    imagesArrayList.add(new Image("sample/pictures/klepiahzwl921.png"));
    borderPane.setPrefSize(450, 450);
    pane.setPrefSize(borderPane.getPrefWidth(), borderPane.getPrefHeight());
    current.fitWidthProperty().bind(pane.prefWidthProperty());
    current.fitHeightProperty().bind(pane.prefHeightProperty());


    Timeline timeline = new Timeline();
    KeyValue transparent = new KeyValue(current.opacityProperty(), 0.0);
    KeyValue opacity = new KeyValue(current.opacityProperty(), 1.0);
    KeyFrame startFadeIn = new KeyFrame(Duration.ZERO, transparent);
    KeyFrame endFadeIn = new KeyFrame(Duration.seconds(5), opacity);
    KeyFrame startFadeOut = new KeyFrame(Duration.seconds(5), transparent);
    KeyFrame endFadeOut = new KeyFrame(Duration.seconds(5.0), e ->{
        count++;
        current.setImage(imagesArrayList.get(count % 3));
    }, transparent);
    timeline.getKeyFrames().addAll(startFadeIn, endFadeIn, startFadeOut, endFadeOut);
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();

    }
公共类控制器实现可初始化{
@FXML公共图像视图当前;
公众形象下一步;
@FXML公共边框窗格边框窗格;
@FXML public Button nextButton=new Button();
静态整数计数=0;
@FXML公共窗格;
ArrayList imagesArrayList=新建ArrayList();
@凌驾
公共void初始化(URL、ResourceBundle、ResourceBundle){
添加(新图像(“/sample/pictures/download.jpg”);
添加(新图像(“/sample/pictures/images.jpg”);
添加(新图像(“sample/pictures/klepiahzwl921.png”);
borderPane.setPrefSize(450450);
setPrefSize(borderPane.getPrefWidth(),borderPane.getPrefHeight());
current.fitWidthProperty().bind(pane.prefWidthProperty());
current.fitHeightProperty().bind(pane.prefHeightProperty());
时间线=新时间线();
KeyValue transparent=新的KeyValue(current.opacityProperty(),0.0);
KeyValue不透明度=新的KeyValue(current.opacityProperty(),1.0);
关键帧startFadeIn=新关键帧(Duration.ZERO,透明);
KeyFrame endFadeIn=新关键帧(持续时间。秒(5),不透明度);
关键帧startFadeOut=新关键帧(持续时间。秒(5),透明);
关键帧结束淡出=新关键帧(持续时间。秒(5.0),e->{
计数++;
current.setImage(imagesArrayList.get(计数%3));
},透明);
timeline.getKeyFrames().addAll(startFadeIn、endFadeIn、startFadeOut、endFadeOut);
timeline.setCycleCount(Animation.unfinite);
timeline.play();
}

顶部和底部为边框窗格的全宽,并垂直调整大小以容纳其组件。左侧和右侧为边框窗格的全高,减去顶部和底部,并水平调整大小以容纳其组件。中间为剩余空间。在您发布的代码中,您设置了bot的首选大小h边框窗格和450x450窗格,除非允许其超出其首选大小,否则不会为边框窗格中的任何其他内容留下任何空间。@James_D因此,如果它在左侧,我应该将其设置为边框窗格的最大高度?在布局期间,左侧窗格将被分配边框窗格的全部高度(如果顶部和底部没有任何内容)。顶部和底部为边框窗格的全宽,并垂直调整大小以容纳其组件。左侧和右侧为边框窗格的全高,减去顶部和底部,并水平调整大小以容纳其组件。中间为剩余空间。在您发布的代码中,您设置了两者的首选大小边框窗格和窗格为450x450,它不会为边框窗格中的任何其他内容留下任何空间,除非允许其超出其首选大小。@James_D因此,如果它在左侧,我应该将其设置为边框窗格的最大高度?左侧窗格将在布局期间分配边框窗格的全部高度(如果顶部和底部没有任何内容)。