简体   繁体   English

JavaFX缩放到全屏

[英]JavaFX scaling to Full screen

I have problem with full screen scaling: I wrote a program in Java with Java FX.The GUI is simple but it has a problem with scaling (to full screen). 我在全屏缩放时遇到问题:我用Java FX用Java编写了一个程序.GUI很简单,但是在缩放到全屏时有问题。 小时的程序GUI

When I put picture to full screen the middle part of the screen is not scaled to full screen. 当我将图片放到全屏时,屏幕的中间部分不会缩放到全屏。 look at the picture 看图片 全屏GUI This second picture is 1920 pixel width. 第二张图片为1920像素宽度。 The width is not set up correctly. 宽度设置不正确。 Until around 1500 pixel width there is some error that prevent to make full screen. 直到出现1500像素左右的宽度为止,都会出现一些错误,导致无法全屏显示。

The middle part has AnchorPlane ->BorderPlane (until this is ok) Then in the middle of Border plane everything stops in scaling: Border Plane Center -> HBox plane -> Border plane - top for file button and middle for TextArea. 中间部分有AnchorPlane-> BorderPlane(直到可以),然后在Border平面的中间停止缩放:Border Plane Center-> HBox plane-> Border plane-顶部为文件按钮,中间为TextArea。 For both max width and max hight are set the max values maxWidth="1.7976931348623157E308" but they are not scaling correctly after some value. 对于最大宽度和最大高度都设置了最大值maxWidth =“ 1.7976931348623157E308”,但是在某些值之后它们不能正确缩放。

What is here a problem? 这是什么问题?

<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>

Set the hgrow property on each of the child elements of the HBox to Priority.ALWAYS : HBox每个子元素的hgrow属性设置为Priority.ALWAYS

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

As per the documentation (my emphasis): 根据文档 (我的重点):

Sets the horizontal grow priority for the child when contained by an hbox. 设置hbox包含时的子级的水平增长优先级。 If set, the hbox will use the priority to allocate additional space if the hbox is resized larger than it's preferred width. 如果设置,则如果将hbox的大小调整为大于其首选宽度,则hbox将使用优先级分配其他空间。 If multiple hbox children have the same horizontal grow priority, then the extra space will be split evening between them. 如果多个hbox子级具有相同的水平增长优先级,则多余的空间将在它们之间分配。 If no horizontal grow priority is set on a child, the hbox will never allocate it additional horizontal space if available. 如果未对子级设置水平增长优先级,则hbox永远不会为其分配额外的水平空间(如果有)。 Setting the value to null will remove the constraint. 将值设置为null将删除约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM