Domi
Domi

Reputation: 1389

GWT add a widget above the existing widget

I have a VericalPanel. If I add an element to it, it will be added under the element, now how can I place an Element over it?

VerticapPanel vpanel  = new VerticalPanel()

Upvotes: 0

Views: 1045

Answers (2)

Jens
Jens

Reputation: 69440

Try the insert method:

Here the description of the method regarding the documentation

protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert)

Insert a new child Widget into this Panel at a specified index, attaching its Element to the specified container Element. The child Element will either be attached to the container at the same index, or simply appended to the container, depending on the value of domInsert.

Parameters:
child - the child Widget to be added
container - the Element within which child will be contained
beforeIndex - the index before which child will be inserted
domInsert - if true, insert child into container at beforeIndex; otherwise append child to the end of container.

Upvotes: 2

Baz
Baz

Reputation: 36894

You can use

VerticalPanel#insert(Widget w, int beforeIndex)

instead of

VerticalPanel#add(Widget w)

This will insert the widget at the given position.

Upvotes: 3

Related Questions