What is the equivalent of setresizeweight() on splitpane in JavaFX?

In swing, we can use setresizeweight () on jsplitpane to determine which part of splitpane gets free space Is there an equivalent method in JavaFX 2.2? I can only find the setdividerposition () method that doesn't really do what I want (I can call it manually every time the size changes, but I want to avoid doing so if possible.)

I can also call setresizablewithparent (false), but this does not provide the kind of control I pursue

Solution

When browsing the API of splitpane, I found this static function - setresizablewithparent (root, Boolean. False), which provides functions similar to 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 imitate the values of setresizeweight (0) and setresizeweight (1), but there is absolutely no difference between them Basically, nodes can be free flowing or fixed

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>