javafx内部控件自动拉伸设置
< 返回列表时间: 2020-07-14来源:OSCHINA
1、使用HBOX和VBox包含控件,这样内部控件就有VGrow和HGrow属性,就可以进行自动拉伸的设置。
2、AnchorPane控件包含的内部控件可以使用AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"让内部控件拉伸到外部控件。 <AnchorPane fx:id="anchorpane" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="641.0" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.joe.readwritemacs.controller.WriteReadMacViewController"> <children> <VBox fx:id="vbox" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="52.0" prefWidth="698.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="0.0"> <children> <MenuBar fx:id="menuBar" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> <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> <Button fx:id="btn" mnemonicParsing="false" text="Button" /> </children></VBox> </children> </AnchorPane>
热门排行