gpt4 book ai didi

JavaFX 缩放至全屏

转载 作者:行者123 更新时间:2023-12-02 04:31:06 25 4
gpt4 key购买 nike

我在全屏缩放方面遇到问题:我用 Java FX 编写了一个 Java 程序。GUI 很简单,但在缩放(全屏)方面存在问题。 Program GUI when small

当我将图片全屏显示时,屏幕的中间部分不会缩放为全屏。看图GUI on full screen第二张图片的宽度为 1920 像素。宽度设置不正确。直到大约 1500 像素宽度时,都会出现一些错误,导致无法充分显示屏幕。

中间部分有 AnchorPlane ->BorderPlane (直到这没问题)然后在边界平面的中间,一切都停止缩放:边界平面中心 -> HBox 平面 -> 边界平面 - 顶部为文件按钮,中间为文本区域。对于最大宽度和最大高度,都设置了最大值 maxWidth="1.7976931348623157E308",但在某个值之后它们无法正确缩放。

这里有什么问题吗?

<AnchorPane id="AnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="700.0" prefWidth="900.0" xmlns:fx="http://javafx.com/fxml" fx:controller="migrationscripts.SampleController">
<children>
<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<bottom>
<TextArea fx:id="help" prefHeight="25.0" promptText="Hints of usage" wrapText="true" />
</bottom>
<center>
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<children>
<BorderPane>
<center>
<TextArea fx:id="prvi" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" promptText="Inuput file" wrapText="true">
<BorderPane.margin>
<Insets top="5.0" fx:id="x3" />
</BorderPane.margin>
</TextArea>
</center>
<top>
<BorderPane>
<center>
<TextField fx:id="labelFile1" maxWidth="1.7976931348623157E308" />
</center>
<left>
<Button fx:id="file1" mnemonicParsing="false" onAction="#chooseFile1" text="File1:">
<BorderPane.margin>
<Insets left="5.0" right="5.0" fx:id="x2" />
</BorderPane.margin>
</Button>
</left>
</BorderPane>
</top>
</BorderPane>

最佳答案

HBox 的每个子元素上的 hgrow 属性设置为 Priority.ALWAYS:

<HBox ...>
<children>
<BorderPane HBox.hgrow="ALWAYS">
<!-- ... -->
</BorderPane>
<!-- ... -->
</children>
</HBox>

根据 documentation (我的重点):

Sets the horizontal grow priority for the child when contained by an hbox. If set, the hbox will use the priority to allocate additional space if the hbox is resized larger than it's preferred width. If multiple hbox children have the same horizontal grow priority, then the extra space will be split evening between them. If no horizontal grow priority is set on a child, the hbox will never allocate it additional horizontal space if available. Setting the value to null will remove the constraint.

关于JavaFX 缩放至全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31454617/

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