7

In Swing, we could use setResizeWeight() on JSplitPane to determine what portion of the SplitPane received the available space. Is there an equivalent method in JavaFX 2.2? I can only find the setDividerPosition() method which doesn't really do what I want (granted I could call it manually each time the size changes, but I'd like to avoid that if possible.)

I could also call setResizableWithParent(false), but again that doesn't really provide the sort of control I'm after.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216

1 Answers1

4

While going through the API for SplitPane, I found this static function - setResizableWithParent(root, Boolean.FALSE) which provides similar functionality as setResizeWeight() in JSplitPane.

    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(new Button("Button One"));
    final StackPane sp2 = new StackPane();
    sp2.getChildren().add(new Button("Button Two"));
    final StackPane sp3 = new StackPane();
    sp3.getChildren().add(new Button("Button Three"));
    sp.getItems().addAll(sp1, sp2, sp3);
    sp.setDividerPositions(0.3f, 0.6f, 0.9f);

    SplitPane.setResizableWithParent(sp1, Boolean.FALSE);

    primaryStage.setScene(new Scene(sp, 300, 200));
    primaryStage.setTitle("Welcome to JavaFX!"); 
    primaryStage.sizeToScene(); 
    primaryStage.show();

setResizableWithParent can mimic the values of setResizeWeight(0) and setResizeWeight(1) but absolutely nothing in between. Basically, the node can either be free-flowing or fixed.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
Avik
  • 1,170
  • 10
  • 25
  • Thanks for the answer - but yup, I'm after something with a resize weight of something in between! That's where my difficulty lies it seems... – Michael Berry Oct 11 '12 at 21:37
  • `primaryStage.titleProperty().bind(scene.widthProperty().asString().concat(":").concat(sc.heightProperty().asString())); DoubleBinding wid=scene.widthProperty().add(0);` Tried binding this with `sp1.widthProperty()` but there is no such function in the API. – Avik Oct 12 '12 at 13:08
  • Thanks for this answer, it helped me and yes, a setResizeWeight would be great. – Burkhard Mar 06 '14 at 09:00