0

我有SplitPane一个SplitPane- 两个水平的。我想避免指定绝对宽度/高度。当我不指定宽度/高度时,第二个SplitPane不显示:

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

<?import javafx.scene.control.*?>
<?import javafx.scene.Group?>
<?import javafx.scene.layout.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="500.0" style="-fx-background-color: cornsilk;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <left>
        <ToolBar orientation="VERTICAL">
            <items>
                <Group>
                    <children>
                        <Button rotate="-90.0" text="Project" />
                    </children>
                </Group>
                <Group>
                    <children>
                        <Button rotate="-90.0" text="Structure" />
                    </children>
                </Group>
            </items>
        </ToolBar>
    </left>
    <center>
      <SplitPane dividerPositions="0.25" style="-fx-background-color:red;">
        <items>
          <AnchorPane  style="-fx-background-color:darkblue;"/>
          <AnchorPane  style="-fx-background-color:gold;">
              <children>
                  <SplitPane dividerPositions="0.25">
                      <items>
                          <AnchorPane style="-fx-background-color:khaki;"/>
                          <AnchorPane style="-fx-background-color:lime;"/>
                      </items>
                  </SplitPane>
              </children>
          </AnchorPane>
        </items>
      </SplitPane>
    </center>
</BorderPane>
4

1 回答 1

0

定义SplitPanewith<SplitPane dividerPositions="0.25" AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">解决了这个问题,这里是 MWE:

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

<?import javafx.scene.control.*?>
<?import javafx.scene.Group?>
<?import javafx.scene.layout.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="700.0" style="-fx-background-color: cornsilk;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <left>
        <ToolBar orientation="VERTICAL">
            <items>
                <Group>
                    <children>
                        <Button rotate="-90.0" text="Project" />
                    </children>
                </Group>
                <Group>
                    <children>
                        <Button rotate="-90.0" text="Structure" />
                    </children>
                </Group>
            </items>
        </ToolBar>
    </left>
    <center>
      <SplitPane dividerPositions="0.25" style="-fx-background-color:red;">
        <items>
          <AnchorPane  style="-fx-background-color:green;"/>
          <AnchorPane  style="-fx-background-color:blue;">
              <children>
                  <SplitPane dividerPositions="0.25" AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
                      <items>
                          <AnchorPane style="-fx-background-color:black;"/>
                          <AnchorPane style="-fx-background-color:aqua;"/>
                      </items>
                  </SplitPane>
              </children>
          </AnchorPane>
        </items>
      </SplitPane>
    </center>
</BorderPane>
于 2014-07-17T12:13:10.447 回答