문제

I'm coming from Python whereby I just passed self and I could edit the objects that way.

So I have some code:

public void initLayout() {
        DockLayoutPanel layout = new DockLayoutPanel(Unit.PC);
        layout.addNorth(new HTML(" v0.1"), 2);
        layout.addSouth(new HTML("Footer"), 2);
        layout.addWest(new HTML(""), 2);
        layout.add(new HTML("center"));
        RootLayoutPanel rootLayout = RootLayoutPanel.get();
        rootLayout.add(layout);
    }

This sets out the layout of the panel I'm using. I now want to easily edit/add to parts of these panels with ease. So for example in another method:

private void initPanel() {
        rootlayout.add(some_new_component);

    }

Or even in the future add to scroll bars etc. I know I could create a method which functioned in a way that I can pass it variables to add all the data now, but I want it to be more flexible in that I want to change things later.

도움이 되었습니까?

해결책

You can use the keyword:

this

Referring to your comment, in Java you would write:

this.rootlayout.add(newContent);

the keyword "this" refers to the current object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top