2013-02-26 39 views
8

是否可以將網格窗格擴展爲最大寬度和高度?將GridPane擴展爲最大寬度和高度

我有以下:

<fx:root type="javafx.scene.layout.AnchorPane" xmlns:fx="http://javafx.com/fxml" 
     stylesheets="view/Style.css"> 
    <children> 
     <GridPane xmlns:fx="http://javafx.com/fxml" 
        AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="128.0" 
        AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" 
        hgap="10" vgap="10"> 
      <!--anything--> 
     </GridPane> 
    </children> 
</fx:root> 

,我想擴大網格窗格到(除了下部,從而整個屏幕)由錨窗格中確定的限制

回答

13

嘗試設置maxHeight和GridPane的maxWidth屬性。 GridPane的

maxHeight="Infinity" maxWidth="Infinity" 

和兒童應包含

GridPane.hgrow="always" GridPane.vgrow="always" 
+1

謝謝,但是maxHeight和maxWidth有什麼意義?這部分在我的申請中沒有任何區別。 – Hassan 2015-11-13 22:45:34

5

如果您是直接使用JavaFX沒有FXML。代碼是:

GridPane.setHgrow(childElementOfGridPane, Priority.ALWAYS); 
GridPane.setVgrow(childElementOfGridPane, Priority.ALWAYS); 
相關問題