JavaFX扩展到全屏

时间:2015-07-16 12:48:21

标签: java user-interface javafx plane

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

当我将图片全屏显示时,屏幕的中间部分不会缩放到全屏。看一下图片GUI on full screen 第二张图片是1920像素宽度。宽度未正确设置。直到大约1500像素宽度有一些错误,阻止充满 屏幕。

中间部分有AnchorPlane - > BorderPlane(直到没问题) 然后在边界平面的中间一切都停止缩放: 边境飞机中心 - > HBox平面 - >边框平面 - 文件按钮的顶部和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>

1 个答案:

答案 0 :(得分:2)

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

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

根据documentation(我的重点):

  

设置子项包含的水平增长优先级   横向盒。如果设置,hbox将使用优先级来分配额外的   如果hbox的大小调整大于其首选宽度,则为空格。如果   那么,多个hbox子项具有相同的水平增长优先级   额外的空间将在他们之间分开。 如果没有水平   在孩子上设置增长优先级,hbox永远不会分配它   额外的水平空间(如果可用)。将值设置为null   将删除约束。

相关问题