简体   繁体   中英

JavaFX - ScrollPane and setting the size

I know this is probably obvious, but I've searched and found no solution. I want to have an anchorpane wrapped in a scrollpane. In that scrollpane. I wanted the actual view size to be 1000x1000 but the scrollable area to be 1920x1080. I want the anchorpane to be 1920x1080 (the full size of the scrolled scrollpane).

First question: How do I set the scrollable area size? I set HMax: 1920, HMin: 0, HValue: 0 and VMax: 1080 VMin: 0, VValue: 0. This doesn't seem to be doing the trick, and I only set these values based off information I loosely understood found on the javafx api.

Second question: How do I set the anchorpane to the full (scrollable) size of the scrollpane? I wrapped it in the scrollpane(I'm doing this in scenebuilder) but I am not sure it will automatically fill the entire scrollpane, including when the scroll pane is scrolled.

Set the preferred size of the AnchorPane to 1920x1080. ScrollPane resizes its content to the content's preferred size.

Set the preferred viewport size of the ScrollPane to 1000x1000

anchorPane.setPrefSize(1920, 1080);
scrollPane.setPrefViewportWidth(1000);
scrollPane.setPrefViewportHeight(1000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM