public class AbsolutePanel extends ComplexPanel implements InsertPanel.ForIsWidget
Note that this panel will not automatically resize itself to allow enough room for its absolutely-positioned children. It must be explicitly sized in order to make room for them.
Once a widget has been added to an absolute panel, the panel effectively "owns" the positioning of the widget. Any existing positioning attributes on the widget may be modified by the panel.
AbsolutePanel elements in UiBinder
templates lay out their children with absolute position, using
<g:at> elements. Each at element should have left
and
top
attributes in pixels. They also can contain widget children
directly, with no position specified.
For example:
<g:AbsolutePanel> <g:at left='10' top='20'> <g:Label>Lorem ipsum...</g:Label> </g:at> <g:Label>...dolores est.</g:Label> </g:AbsolutePanel>
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
InsertPanel.ForIsWidget
HasWidgets.ForIsWidget
eventsToSink
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR
Modifier | Constructor and Description |
---|---|
|
AbsolutePanel()
Creates an empty absolute panel.
|
protected |
AbsolutePanel(Element elem)
Creates an AbsolutePanel with the given element.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IsWidget w,
int left,
int top)
Overloaded version for IsWidget.
|
void |
add(Widget w)
Adds a child widget.
|
void |
add(Widget w,
int left,
int top)
Adds a widget to the panel at the specified position.
|
int |
getWidgetLeft(Widget w)
Gets the position of the left outer border edge of the widget relative to
the left outer border edge of the panel.
|
int |
getWidgetTop(Widget w)
Gets the position of the top outer border edge of the widget relative to
the top outer border edge of the panel.
|
void |
insert(IsWidget w,
int beforeIndex)
Convenience overload to allow
IsWidget to be used directly. |
void |
insert(Widget w,
int beforeIndex)
Inserts a child widget before the specified index.
|
void |
insert(Widget w,
int left,
int top,
int beforeIndex)
Inserts a child widget at the specified position before the specified
index.
|
boolean |
remove(Widget w)
Overrides
ComplexPanel.remove(Widget) to change the removed
Widget's element back to static positioning.This is done so that any
positioning changes to the widget that were done by the panel are undone
when the widget is disowned from the panel. |
void |
setWidgetPosition(Widget w,
int left,
int top)
Sets the position of the specified child widget.
|
protected void |
setWidgetPositionImpl(Widget w,
int left,
int top) |
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, doLogicalClear, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add
getWidgetIndex
getWidget, getWidgetCount, getWidgetIndex, remove
public AbsolutePanel()
protected AbsolutePanel(Element elem)
RootPanel
or a subclass that wants to substitute
another element. The element is presumed to be a <div>.elem
- the element to be used for this panelpublic void add(Widget w)
Panel
How to Override this Method
There are several important things that must take place in the correct order to properly add or insert a Widget to a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
ComplexPanel.adjustIndex(Widget, int)
.Widget.removeFromParent()
on the
Widget.WidgetCollection
at the appropriate index.Panel.adopt(Widget)
to finalize the add as the
very last step.add
in interface HasWidgets
add
in interface InsertPanel
add
in class Panel
w
- the widget to be addedHasWidgets.add(Widget)
public void add(Widget w, int left, int top)
(-1, -1)
will cause the child widget to be positioned
statically.w
- the widget to be addedleft
- the widget's left positiontop
- the widget's top positionpublic void add(IsWidget w, int left, int top)
add(Widget,int,int)
public int getWidgetLeft(Widget w)
w
- the widget whose position is to be retrievedpublic int getWidgetTop(Widget w)
w
- the widget whose position is to be retrievedpublic void insert(Widget w, int beforeIndex)
InsertPanel
insert
in interface InsertPanel
w
- the child widget to be insertedbeforeIndex
- the index before which it will be insertedpublic void insert(IsWidget w, int beforeIndex)
IsWidget
to be used directly.insert
in interface InsertPanel.ForIsWidget
public void insert(Widget w, int left, int top, int beforeIndex)
(-1, -1)
will cause the child
widget to be positioned statically. If the widget is already a child of
this panel, it will be moved to the specified index.w
- the child widget to be insertedleft
- the widget's left positiontop
- the widget's top positionbeforeIndex
- the index before which it will be insertedjava.lang.IndexOutOfBoundsException
- if beforeIndex
is out of
rangepublic boolean remove(Widget w)
ComplexPanel.remove(Widget)
to change the removed
Widget's element back to static positioning.This is done so that any
positioning changes to the widget that were done by the panel are undone
when the widget is disowned from the panel.remove
in interface HasWidgets
remove
in class ComplexPanel
w
- the widget to be removedtrue
if the child was presentpublic void setWidgetPosition(Widget w, int left, int top)
(-1, -1)
will cause the child widget to be positioned
statically.w
- the child widget to be positionedleft
- the widget's left positiontop
- the widget's top positionprotected void setWidgetPositionImpl(Widget w, int left, int top)