How to resize JavaFX ScrollPane content to fit current size

前端 未结 2 2025
不知归路
不知归路 2020-12-14 05:45

I have a BorderPane with a ScrollPane as the center element. It resizes automatically to fill the screen. Inside the ScrollPane is a <

相关标签:
2条回答
  • 2020-12-14 06:05

    Setting the fitToHeight or fitToWidth attribute through XML or CSS:

    FXML:

    <ScrollPane fx:id="myScrollPane" fitToHeight="true" fitToWidth="true" />
    

    CSS:

    .my-scroll-pane {
        -fx-fit-to-height: true;
        -fx-fit-to-width: true;
    }
    
    0 讨论(0)
  • 2020-12-14 06:11

    Try

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);
    

    without overriding the resize() method.

    0 讨论(0)
提交回复
热议问题