繁体   English   中英

如何使 AnchorPane 随窗口调整大小?

[英]How do you make AnchorPane resize with the window?

我正在使用 Scene Builder 来设计布局。 父节点是一个 AnchorPane,它包含一个应该随它调整大小的 GridPane。 然而,AnchorPane 停止使用 GridPane 调整大小(我认为)。 如何在用鼠标拖动窗口放大时调整其大小?

文件格式:

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>


<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
   <children>
      <GridPane fx:id="gridPane" gridLinesVisible="true" layoutX="10.0" layoutY="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <columnConstraints>
            <ColumnConstraints hgrow="ALWAYS" maxWidth="293.0" minWidth="10.0" prefWidth="163.0" />
            <ColumnConstraints hgrow="ALWAYS" maxWidth="437.0" minWidth="10.0" prefWidth="437.0" />
         </columnConstraints>
         <rowConstraints>
            <RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="29.0" vgrow="NEVER" />
            <RowConstraints maxHeight="351.0" minHeight="10.0" prefHeight="351.0" vgrow="ALWAYS" />
         </rowConstraints>
         <children>
            <MenuBar GridPane.columnSpan="2147483647" GridPane.valignment="TOP">
               <menus>
                  <Menu mnemonicParsing="false" text="File">
                     <items>
                        <MenuItem mnemonicParsing="false" text="Close" />
                     </items>
                  </Menu>
                  <Menu mnemonicParsing="false" text="Edit">
                     <items>
                        <MenuItem mnemonicParsing="false" text="Delete" />
                     </items>
                  </Menu>
                  <Menu mnemonicParsing="false" text="Help">
                     <items>
                        <MenuItem mnemonicParsing="false" text="About" />
                     </items>
                  </Menu>
               </menus>
            </MenuBar>
            <ScrollPane fx:id="mapViewScrollPane" fitToHeight="true" fitToWidth="true" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.vgrow="ALWAYS">
               <content>
                  <ImageView fx:id="mapView" fitWidth="750.0" pickOnBounds="true" preserveRatio="true" />
               </content>
            </ScrollPane>
         </children>
      </GridPane>
   </children>
</AnchorPane>
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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