在ScrollPane中停止GridPane水平拉伸

时间:2017-04-25 14:14:35

标签: javafx width fxml

我正在尝试通过FXML在gridPane中创建表单,其中此表单应该具有垂直滚动,因为内容不适合屏幕高度。但是内容的宽度是Okey.for屏幕大小,但是在添加之后,Scroll Pane中的这个网格窗格开始在视野中延伸。有什么建议可以解决这个问题吗?

<ScrollPane fitToWidth="false"  hbarPolicy="NEVER"  xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" >
<content> 
    <GridPane gridLinesVisible="true" maxWidth="-Infinity" minWidth="-Infinity" >
        <stylesheets>
            <URL value="@estoresurvery.css" />
        </stylesheets>
        <columnConstraints>
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" />
            <ColumnConstraints    hgrow="NEVER" /> 
        </columnConstraints>
        <rowConstraints>
            <RowConstraints percentHeight="20.0" valignment="CENTER"/>
            <RowConstraints percentHeight="5.0" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="15.0" valignment="CENTER"/>
            <RowConstraints percentHeight="7.5" valignment="CENTER" />
            <RowConstraints percentHeight="2.5" valignment="CENTER" />
            <RowConstraints percentHeight="7.5" valignment="TOP"  />
            <RowConstraints percentHeight="2.5" valignment="TOP"  />
        </rowConstraints>
        <children>
            <Button alignment="TOP_CENTER" styleClass="logoHeader" GridPane.columnSpan="12" GridPane.halignment="CENTER" GridPane.rowIndex="0" />
        </children>
        <children>
            <Text styleClass="howHelpTxt" GridPane.columnIndex="1" GridPane.columnSpan="10" GridPane.halignment="CENTER" GridPane.rowIndex="1"> 
                SomeTEXT    
            </Text>
        </children>
        <children>
            <Text styleClass="fieldText" GridPane.columnIndex="1" GridPane.columnSpan="10" GridPane.halignment="CENTER" GridPane.rowIndex="2"> 
                SomeTEXT      
            </Text> 
        </children>
        <children>
            <TextField fx:id="NameTxt" styleClass="txtBox" GridPane.columnIndex="2" GridPane.columnSpan="8" GridPane.rowIndex="3" />
        </children>
        <children>
            <Text styleClass="fieldText" GridPane.columnSpan="12" GridPane.halignment="CENTER" GridPane.rowIndex="4"> 
                SomeTEXT
            </Text>
        </children>
        <children>
            <TextField fx:id="PhonelTxt" styleClass="txtBox" GridPane.columnIndex="2" GridPane.columnSpan="8" GridPane.rowIndex="5" />
        </children>
        <children>
            <Text styleClass="fieldText" GridPane.columnSpan="12" GridPane.halignment="CENTER" GridPane.rowIndex="6"> 
                SomeTEXT     
            </Text>
        </children>
        <children>
            <TextField fx:id="EmailTxt" styleClass="txtBox" GridPane.columnIndex="2" GridPane.columnSpan="8" GridPane.rowIndex="7" />
        </children>
        <children>
            <Button onAction="#showModle" styleClass="agrrementTxt" text="SomeText" GridPane.columnIndex="1" GridPane.columnSpan="10" GridPane.halignment="center" GridPane.rowIndex="8" />    
        </children>
        <children>
            <Button styleClass="yesBox" GridPane.columnIndex="2" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="9">
                SomeTEXT  
            </Button>
            <Button styleClass="NoBox" GridPane.columnIndex="7" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="9">
                SomeTEXT 
            </Button>
        </children>
        <children>
            <Button onAction="#showThanksMessage" styleClass="NoBox" GridPane.columnIndex="4" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.rowIndex="11">
                SomeTEXT
            </Button>  
        </children>
    </GridPane>
</content>

0 个答案:

没有答案