拖动窗格以在 JavaFX 中展开或缩小
Drag Pane to Expand or Shrink in JavaFX
我的 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>
我想拖动第一个窗格和第二个窗格之间的边框。所以-
当我向左拖动边框时,第一个窗格变小,第二个窗格变大。
当我向右拖动边框时,第一个窗格变大,第二个窗格变小。
希望下图能说明我的要求。
您应该将第一个和第二个窗格放入 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>
我的 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>
我想拖动第一个窗格和第二个窗格之间的边框。所以-
当我向左拖动边框时,第一个窗格变小,第二个窗格变大。
当我向右拖动边框时,第一个窗格变大,第二个窗格变小。
希望下图能说明我的要求。
您应该将第一个和第二个窗格放入 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>