【发布时间】:2013-06-05 12:41:58
【问题描述】:
我很感兴趣如何将ScrollPane 添加到主舞台。当我减小主页的大小时,我想使用ScrollPane 移动到主舞台上。有例子吗?
【问题讨论】:
我很感兴趣如何将ScrollPane 添加到主舞台。当我减小主页的大小时,我想使用ScrollPane 移动到主舞台上。有例子吗?
【问题讨论】:
如果ScrollPane 的内容大于ScrollPane 的允许大小,ScrollPane 应自动附加滚动条。这是一个例子:
public class JFXScroll extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane main = new BorderPane();
ScrollPane scroll = new ScrollPane();
VBox box = new VBox();
// Demo purposes; Wouldn't normally do this - just let the box automatically fit the content
box.setPrefSize(1000, 500);
box.setEffect(new ColorInput(0,0,1000,500,Color.LIME));
scroll.setContent(box);
main.setLeft(new Label("Left Content"));
main.setCenter(scroll);
Scene scene = new Scene(main, 300, 250);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
【讨论】:
stage.setScene(new ScrollPane(yourContent)); 应该这样做。
当然,您的内容应该有适当的最小、最大和首选尺寸
【讨论】: