2014-06-10 94 views
0

我使用此代碼杉FlowPane到ScrollPane中飛度FlowPane到ScrollPane中

FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL); 
ScrollPane scroll = new ScrollPane(); 
scroll.setContent(flowPane); 
scroll.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() 
{ 
    @Override 
    public void changed(ObservableValue<? extends Bounds> ov, Bounds oldBounds, Bounds bounds) 
    { 
     flowPane.setPrefWidth(bounds.getWidth()); 
     flowPane.setPrefHeight(bounds.getHeight()); 
    } 
}); 

可惜,這也許不是最好的解決方案。是否有另一種更簡單的方法將FlowPane整合到Java 8的ScrollPane中?

回答

0

嘗試或者通過CSS或通過API,從而提供了極大的擴展whithin容器放置你的flowPane的maxWidthmaxHeoght屬性Double.MAX_VALUE

flowPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); 
+0

由於某種原因,它無法正常工作。還有其他解決方案嗎? –

+0

也許將prefSize也設置爲MAX_VALUE? – xuesheng

4

有滾動窗格的方法意味着要做到這一點:

scrollPane.setFitToWidth(true); 
scrollPane.setFitToHeight(true);