public class CustomScrollPanel extends ScrollPanel
ScrollPanel
that allows user provided
scrollbars.
The postion of scrollbars in a CustomScrollPanel
differs from that of
a native scrollable element. In a native element, scrollbars appear adjacent
to the content, shrinking the content client height and width when they
appear. CustomScrollPanel
instead overlays scrollbars on top of the
content, so the content does not change size when scrollbars appear. If the
scrollbars obscures the content, you can set the padding-top
and
padding-bottom
of the content to shift the content out from
under the scrollbars.
NOTE: Unlike ScrollPanel
, which implements RequiresResize
but
doesn't really require it, CustomScrollPanel
actually does require
resize and should only be added to a panel that implements
ProvidesResize
, such as most layout panels and
ResizeLayoutPanel
.
Modifier and Type | Class and Description |
---|---|
static interface |
CustomScrollPanel.Resources
A ClientBundle of resources used by this widget.
|
static interface |
CustomScrollPanel.Style
Styles used by this widget.
|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasWidgets.ForIsWidget
DEBUG_ID_PREFIX
Constructor and Description |
---|
CustomScrollPanel()
Creates an empty
CustomScrollPanel . |
CustomScrollPanel(CustomScrollPanel.Resources resources) |
CustomScrollPanel(Widget child)
Creates a
CustomScrollPanel with the specified child widget. |
Modifier and Type | Method and Description |
---|---|
protected void |
doAttachChildren()
If a widget contains one or more child widgets that are not in the logical
widget hierarchy (the child is physically connected only on the DOM level),
it must override this method and call
Widget.onAttach() for each of its
child widgets. |
protected void |
doDetachChildren()
If a widget contains one or more child widgets that are not in the logical
widget hierarchy (the child is physically connected only on the DOM level),
it must override this method and call
Widget.onDetach() for each of its
child widgets. |
HorizontalScrollbar |
getHorizontalScrollbar()
Get the scrollbar used for horizontal scrolling.
|
VerticalScrollbar |
getVerticalScrollbar()
Get the scrollbar used for vertical scrolling.
|
protected void |
onAttach()
This method is called when a widget is attached to the browser's document.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onDetach()
This method is called when a widget is detached from the browser's
document.
|
protected void |
onLoad()
This method is called immediately after a widget becomes attached to the
browser's document.
|
void |
onResize()
This method must be called whenever the implementor's size has been
modified.
|
boolean |
remove(Widget w)
Removes a child widget.
|
void |
removeHorizontalScrollbar()
Remove the
HorizontalScrollbar , if one exists. |
void |
removeVerticalScrollbar()
Remove the
VerticalScrollbar , if one exists. |
void |
setAlwaysShowScrollBars(boolean alwaysShow)
Sets whether this panel always shows its scroll bars, or only when
necessary.
|
void |
setHorizontalScrollbar(HorizontalScrollbar scrollbar,
int height)
Set the scrollbar used for horizontal scrolling.
|
void |
setVerticalScrollbar(VerticalScrollbar scrollbar,
int width)
Set the scrollbar used for vertical scrolling.
|
void |
setWidget(Widget w)
Sets this panel's widget.
|
addScrollHandler, addScrollListener, ensureVisible, getContainerElement, getHorizontalScrollPosition, getMaximumHorizontalScrollPosition, getMaximumVerticalScrollPosition, getMinimumHorizontalScrollPosition, getMinimumVerticalScrollPosition, getScrollableElement, getScrollPosition, getVerticalScrollPosition, isTouchScrollingDisabled, removeScrollListener, scrollToBottom, scrollToLeft, scrollToRight, scrollToTop, setHeight, setHorizontalScrollPosition, setScrollPosition, setSize, setTouchScrollingDisabled, setVerticalScrollPosition, setWidth
add, getWidget, iterator, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onUnload, removeFromParent, setLayoutData, 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, setPixelSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString
fireEvent
forEach, spliterator
public CustomScrollPanel()
CustomScrollPanel
.public CustomScrollPanel(CustomScrollPanel.Resources resources)
public CustomScrollPanel(Widget child)
CustomScrollPanel
with the specified child widget.child
- the widget to be wrapped by the scroll panelpublic HorizontalScrollbar getHorizontalScrollbar()
public VerticalScrollbar getVerticalScrollbar()
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event receivedpublic void onResize()
RequiresResize
onResize
in interface RequiresResize
onResize
in class ScrollPanel
public boolean remove(Widget w)
Panel
How to Override this Method
There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
false
if it is not.Panel.orphan(Widget)
first while the child
Widget is still attached.WidgetCollection
.remove
in interface HasWidgets
remove
in class SimplePanel
w
- the widget to be removedtrue
if the child was presentpublic void removeHorizontalScrollbar()
HorizontalScrollbar
, if one exists.public void removeVerticalScrollbar()
VerticalScrollbar
, if one exists.public void setAlwaysShowScrollBars(boolean alwaysShow)
ScrollPanel
setAlwaysShowScrollBars
in class ScrollPanel
alwaysShow
- true
to show scroll bars at all timespublic void setHorizontalScrollbar(HorizontalScrollbar scrollbar, int height)
scrollbar
- the scrollbar, or null to clear itheight
- the height of the scrollbar in pixelspublic void setVerticalScrollbar(VerticalScrollbar scrollbar, int width)
scrollbar
- the scrollbar, or null to clear itwidth
- the width of the scrollbar in pixelspublic void setWidget(Widget w)
SimplePanel
setWidget
in interface HasOneWidget
setWidget
in class SimplePanel
w
- the panel's new widget, or null
to clear the panelprotected void doAttachChildren()
Widget
Widget.onAttach()
for each of its
child widgets.doAttachChildren
in class Panel
Widget.onAttach()
protected void doDetachChildren()
Widget
Widget.onDetach()
for each of its
child widgets.doDetachChildren
in class Panel
Widget.onDetach()
protected void onAttach()
Widget
This method is called when a widget is attached to the browser's document.
To receive notification after a Widget has been added to the document,
override the Widget.onLoad()
method or use Widget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler)
.
It is strongly recommended that you override Widget.onLoad()
or
Widget.doAttachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onAttach()
to ensure that the Widget has been attached
to its underlying Element.
onAttach
in class ScrollPanel
Widget.onLoad()
,
Widget.doAttachChildren()
protected void onDetach()
Widget
This method is called when a widget is detached from the browser's
document. To receive notification before a Widget is removed from the
document, override the Widget.onUnload()
method or use Widget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler)
.
It is strongly recommended that you override Widget.onUnload()
or
Widget.doDetachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
onDetach
in class ScrollPanel
Widget.onUnload()
,
Widget.doDetachChildren()
Copyright © 2018. All rights reserved.