2

2 つのコンポーネントを分割する垂直分割ペインがあるレイアウトがあります。分割ペインの右側にあるコンポーネントを拡大したい (これは画像です) が、分割ペインの左側にあるコンポーネントは、ウィンドウ拡大されます。

左側の AnchorPane を Vbox でラップしようとしましたが、ウィンドウのサイズが変更されたときに左側のすべてのコンポーネントが下に移動する場合を除いて、機能するように見えました。これは、HBox でラップした場合にも発生します。

これを修正する最善の方法が思いつきません。私は Scene Builder を使用していますが、Javafx にはまだ慣れていません。誰でも助けることができますか?

ありがとうございました!

4

1 に答える 1

7

同じ固定値で拡大してはならないコンポーネントで と を呼び出すsetMinWidthと、ユーザーは分割線の位置を変更できなくなります。setMaxWidth

たとえば100、左のコンポーネントの最大サイズが必要だとすると、コードは次のようになります。

SplitPane pane = new SplitPane();

double leftComponentSize = 100.0;
VBox leftComponent = new VBox();
// Set the min and max width to a fixed size
leftComponent.setMinWidth(leftComponentSize);
leftComponent.setMaxWidth(leftComponentSize);
...
pane.getItems().addAll(leftComponent, rightComponent);
// Initialize the divider positions to allocate the expected size 
// to the left component according to the size of the window
pane.setDividerPositions(leftComponentSize / stage.getScene().getWidth());
于 2015-11-23T11:13:31.760 に答える