gpt4 book ai didi

JavaFX 2.2 : buttons goes out of the Vbox layout when shrinking the stage

转载 作者:行者123 更新时间:2023-12-01 04:50:05 25 4
gpt4 key购买 nike

我正在使用 javafx 构建示例 CRUD 应用程序,这是我的 FXML 文件:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<BorderPane fx:id="root" depthTest="ENABLE" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
xmlns:fx="http://javafx.com/fxml" fx:controller="org.tarrsalah.persona.gui.MainViewPresenter">

<center>
<TableView fx:id="table" minHeight="500.0" minWidth="600.0" prefHeight="-1.0" prefWidth="-1.0">
<columns>
<TableColumn prefWidth="75.0" text="name" fx:id="name" />
<TableColumn prefWidth="75.0" text="last name" fx:id="lastname" />
</columns>
<BorderPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</BorderPane.margin>
</TableView>
</center>

<right>
<VBox VBox.vgrow="ALWAYS" fillWidth="true" spacing="10.0" BorderPane.alignment="TOP_LEFT" minWidth="200" >
<children >
<Button fx:id="newP" prefWidth="100.0" minWidth="80" text="New" VBox.vgrow="NEVER" />
<Button fx:id="alter" prefWidth="100.0" minWidth="80" text="Alter" VBox.vgrow="NEVER" />
<Button fx:id="remove" prefWidth="100.0" minWidth="80" text="remove" VBox.vgrow="NEVER" />
</children>
<padding>
<Insets left="20.0" right="20.0" top="10.0" />
</padding>
</VBox>
</right>
</BorderPane>

当尝试调整舞台大小时,所有按钮都会脱离 Vbox 布局,如您所见

before shrinkin after shrinking

如何防止 Vbox Pane 缩小?

最佳答案

此行为是由 TableView 上的最小宽度约束引起的。

<TableView fx:id="table" minHeight="500.0" minWidth="600.0" prefHeight="-1.0" prefWidth="-1.0">

您应该删除属性minWidth="600.0",以允许TableView将其宽度减小到600px以下。

关于JavaFX 2.2 : buttons goes out of the Vbox layout when shrinking the stage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15135589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com