質問

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