[英]How to force text area to resize fxml
I am currently working on a small application. 我目前正在开发一个小型应用程序。 I am currently working on the gui and I have everything layed out.
我目前正在使用gui,并且已进行了所有布置。 It currently looks like this:
当前看起来像这样:
I want the text area to fill the gray area below it. 我希望文本区域填充其下方的灰色区域。 To be clear, I do not want it to resize with the content like all other questions here, just to fill the gray area.
明确地说,我不希望它像这里的所有其他问题一样使用内容来调整大小,只是为了填充灰色区域。 I cannot set a static size because the gui is sized based on the users display.
我无法设置静态大小,因为gui的大小基于用户显示的大小。 All I want is for the text area to cover the gray box below it.
我想要的只是文本区域覆盖其下方的灰色框。
Here is the FXML: 这是FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="code.matthew.todo.ControllerMain">
<left>
<ListView fx:id="todoList" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</left>
<center>
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<Label fx:id="todoName" text="Name:" />
<Label fx:id="todoDueBy" text="Due by:" />
<TextArea fx:id="todoInfo" prefHeight="206.0" prefWidth="100.0" wrapText="true" />
</children>
</VBox>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem fx:id="newTodo" mnemonicParsing="false" onAction="#newTODO" text="New" />
<MenuItem fx:id="deleteTodo" mnemonicParsing="false" text="Delete" />
<MenuItem fx:id="closeApp" mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="Help" />
<MenuItem mnemonicParsing="false" text="Settings" />
<MenuItem fx:id="menuAbout" mnemonicParsing="false" onAction="#openAbout" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
Thanks! 谢谢!
将TextArea
的VBox.vgrow
属性设置为ALWAYS
:
<TextArea fx:id="todoInfo" prefHeight="206.0" prefWidth="100.0" wrapText="true" VBox.vgrow="ALWAYS" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.