Equivalent of setResizeWeight() on SplitPane in JavaFX?

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.


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.

链接地址: http://www.djcxy.com/p/64222.html

上一篇: 宽度不会缩小?

下一篇: JavaFX中的SplitPane上的setResizeWeight()的等价物?