[英]JavaFX scaling to Full screen
我在全屏缩放时遇到问题:我用Java FX用Java编写了一个程序.GUI很简单,但是在缩放到全屏时有问题。
当我将图片放到全屏时,屏幕的中间部分不会缩放到全屏。 看图片 第二张图片为1920像素宽度。 宽度设置不正确。 直到出现1500像素左右的宽度为止,都会出现一些错误,导致无法全屏显示。
中间部分有AnchorPlane-> BorderPlane(直到可以),然后在Border平面的中间停止缩放:Border Plane Center-> HBox plane-> Border plane-顶部为文件按钮,中间为TextArea。 对于最大宽度和最大高度都设置了最大值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>
根据文档 (我的重点):
设置hbox包含时的子级的水平增长优先级。 如果设置,则如果将hbox的大小调整为大于其首选宽度,则hbox将使用优先级分配其他空间。 如果多个hbox子级具有相同的水平增长优先级,则多余的空间将在它们之间分配。 如果未对子级设置水平增长优先级,则hbox永远不会为其分配额外的水平空间(如果有)。 将值设置为null将删除约束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.