简体   繁体   中英

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). 小时的程序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. The width is not set up correctly. Until around 1500 pixel width there is some error that prevent to make full screen.

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. For both max width and max hight are set the max values maxWidth="1.7976931348623157E308" but they are not scaling correctly after some value.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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