如何根据窗口大小重新定位Labels和TextFields

时间:2015-01-16 17:04:38

标签: javafx label textfield maximize

我的fxml文件中有一些文本字段和标签。所有这些都躺在一个Anchor Pane上。当我最大化窗格时,TableViews被正确地重新定位,标签和文本字段不会改变位置,因此所有这些都看起来不同步。任何线索都会有所帮助。

以下是模拟问题的代码。当你最大化fxml时,标题就会失败。

FXMLDocument.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"  fx:controller="testbed.FXMLDocumentController">
<children>
    <Label fx:id="label" layoutX="126" layoutY="120" minHeight="16" minWidth="69" />
  <SplitPane dividerPositions="0.14715719063545152" layoutX="175.0" layoutY="74.0" orientation="VERTICAL" prefHeight="600.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
    <items>
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
           <children>
              <Label layoutX="234.0" layoutY="32.0" text="MAIN HEADING ">
                 <font>
                    <Font size="18.0" />
                 </font>
              </Label>
           </children>
        </AnchorPane>
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
           <children>
              <SplitPane dividerPositions="0.4949664429530201" layoutX="52.0" layoutY="140.0" prefHeight="507.0" prefWidth="598.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                <items>
                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
                </items>
              </SplitPane>
           </children>
        </AnchorPane>
    </items>
  </SplitPane>
</children>

0 个答案:

没有答案