How to programly add things to splitpane?

Hi,
My project has hundreds of screens, and now there is a requirement to change the layout. It is required to add a split pane, and then add original content to left side, and add new content to right side.
I know how to achive this by modify the screen xml file, but manually changing hundreds of files costs time. I want to implement this by modify the Java file, the hundreds of old screen base on same ancestor class.

But I didnot find how to add spltpane programly even for a simple case.

Could you share how to?

Hi!

If you want to add components to SplitPanel programmatically, you can use the add method. SplitPanel can contain only two components and if you add more than two, you will see an exception. The first ‘add’ will set component on the left side (if the orientation is horizontal) or on the top side (if the orientation is vertical) and second ‘add’ will set to the other side.

Code example:

@Inject
private SplitPanel split;

@Inject
private ComponentsFactory factory;

@Override
public void init(Map<String, Object> params) {
    Label firstLabel = factory.createComponent(Label.class);
    firstLabel.setValue("First");

    VBoxLayout firstComponent = factory.createComponent(VBoxLayout.class);
    firstComponent.add(firstLabel);

    split.add(firstComponent);

    Label secondLabel = factory.createComponent(Label.class);
    secondLabel.setValue("Second");

    VBoxLayout secondComponent = factory.createComponent(VBoxLayout.class);
    secondComponent.add(secondLabel);

    split.add(secondComponent);

}