拖动窗格以在JavaFX中展开或缩小

时间:2017-05-14 15:12:22

标签: java javafx fxml

我的HBox中有三个窗格。

<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
   <children>
      <Pane id="First" prefHeight="200.0" prefWidth="200.0" />
      <Pane id="Second" prefHeight="200.0" prefWidth="200.0" />
      <Pane id="Third" prefHeight="200.0" prefWidth="200.0" />
   </children>
</HBox>

我想拖动First Pane&amp; amp;第二个窗格。那样 -

  1. 当我将边框向左拖动时,第一个窗格变小,第二个窗格变大。

  2. 当我将边框向右拖动时,第一个窗格变大,第二个窗格变小。

  3. 我希望下面的图片能解释我的要求。

    enter image description here

1 个答案:

答案 0 :(得分:0)

您应该将第一个和第二个窗格放入SplitPane:

<HBox prefHeight="100.0" prefWidth="200.0">
    <SplitPane>
        <Pane id="First" prefHeight="200.0" prefWidth="200.0"/>
        <Pane id="Second" prefHeight="200.0" prefWidth="200.0"/>
    </SplitPane>
    <Pane id="Third" prefHeight="200.0" prefWidth="200.0"/>
</HBox>