Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class Sheet

  1. Object
  2. Component
  3. Container
  4. Sheet

ImplementsAnimation, Editable, Iterable<Component>, StyleListener

A light-weight dialog that slides up from the bottom of the screen on mobile devices. Sheets include a “title” bar, with a back/close button, a title label, and a “commands container” (#getCommandsContainer()) which allows you to insert your own custom components (usually buttons) in the upper right.

Custom content should be placed inside the content pane which can be retrieved via #getContentPane()

Usage

The general usage is to create new Sheet instance (or subclass), then call #show() to make it appear over the current form. If a different sheet that is currently being displayed, then calling #show() will replace it.

Inter-Sheet Navigation

The java.lang.String) constructor can take another Sheet object as a parameter, which will act as a “parent” sheet (#getParentSheet(). If the parent sheet is not null, then this sheet will have a “Back” button instead of a “Close” button. THe “Back” button will navigate back to the parent sheet.

When navigating between sheets, the sheet will be resized with a smooth slide animation to the preferred height of the destination sheet.

Example

`public void start() {
if(current != null){
current.show();
return;`
Form hi = new Form("Hi World", new BorderLayout());

Button b = new Button("Open Sheet");
b.addActionListener(e->{
new MySheet(null).show();

});
hi.add(BorderLayout.NORTH, b);
hi.show();
}

private class MySheet extends Sheet {
MySheet(Sheet parent) {
super(parent, "My Sheet");
Container cnt = getContentPane();
cnt.setLayout(BoxLayout.y());
Button gotoSheet2 = new Button("Goto Sheet 2");
gotoSheet2.addActionListener(e->{
new MySheet2(this).show(300);
});
cnt.add(gotoSheet2);
for (String t : new String[]{"Red", "Green", "Blue", "Orange"}) {
cnt.add(new Label(t));
}
}
}

private class MySheet2 extends Sheet {
MySheet2(Sheet parent) {
super(parent, "Sheet 2");
Container cnt = getContentPane();
cnt.setLayout(BoxLayout.y());
cnt.setScrollableY(true);
for (int i=0; iVideo Sample

[Screen cast of the SheetSample demo](https://youtu.be/3okEj_JW3-k)

View source for this sample [here](https://github.com/codenameone/CodenameOne/tree/master/Samples/samples/SheetSample).
This sample can be run directly in the [SampleRunner](https://github.com/codenameone/CodenameOne/tree/master/Samples/).

Constructors

public Sheet(Sheet parent, String title)Creates a new sheet with the specified parent and title.
public Sheet(Sheet parent, String title, String uiid)Creates a new sheet with the specified parent and title.

Methods

public void setDetents(float... fractions)Lets the user drag the sheet between resting heights, as iOS sheet detents and Android’s half-expanded bottom sheet do.
public float[] getDetents()The resting heights set with #setDetents(float...).
public int getDetentIndex()The detent the sheet rests at.
public void setDetentIndex(int index)Moves the sheet to one of its detents, animating when it is showing.
public void addDetentListener(ActionListener l)Listens for the sheet settling at a different detent, by a drag or #setDetentIndex(int).
public void removeDetentListener(ActionListener l)Removes a detent listener.
protected Dimension calcPreferredSize()Calculates the preferred size based on component content.
public static boolean isSheetVisibleAt(int x, int y)
public void setTopLevelHost(TopLevelContainer host)Sets the top level this sheet appears on, which may be a com.codename1.ui.Window rather than the current Form.
public TopLevelContainer getTopLevelHost()Returns the top level set with #setTopLevelHost(TopLevelContainer).
public static Sheet getCurrentSheet()Gets the current sheet on the current form or null if no sheet is currently being displayed.
public static Sheet getCurrentSheet(TopLevelContainer top)Gets the sheet currently showing on the given top level, or null.
public static Sheet findContainingSheet(Component cmp)Finds Sheet containing this component if it is currently part of a Sheet.
public boolean isAllowClose()Checks whether the user is allowed to close this sheet.
public void setAllowClose(boolean allowClose)Sets whether the user is able to close this sheet.
public boolean isSwipeToDismissEnabled()Checks whether this sheet can be dismissed by swiping it toward the edge of the screen (e.g. swiping down for a south-positioned sheet).
public void setSwipeToDismissEnabled(boolean swipeToDismissEnabled)Enables or disables the swipe-to-dismiss gesture.
public Container getContentPane()Gets the content pane of the sheet.
public void hideBackButton()Hides the back button.
public void showBackButton()Shows the back button.
public Container getCommandsContainer()Gets the container that is rendered on the top right bar of the sheet.
public String getTitle()Gets the title text displayed in the default title label.
public void setTitle(String title)Sets the title text displayed in the default title label.
public Component getTitleComponent()Gets the component currently used in the center of the title bar.
public void setTitleComponent(Component cmp)Sets the title component rendered in the center of the title bar.
public void show()Shows the sheet with the default (300ms) transition duration.
public <T> AsyncResource<T> showForResult()Shows the sheet and returns an AsyncResource that will be completed when the sheet finishes – either with #finish(Object) carrying a chosen value, or with null when the sheet is dismissed via back/swipe.
public <T> AsyncResource<T> showForResult(int duration)#showForResult with a custom slide duration.
public void finish(Object result)Completes the result resource returned by #showForResult and dismisses the sheet.
public void show(int duration)Shows the sheet over the current form using a slide-up transition with given duration in milliseconds.
public Button addAction(String text, ActionListener l)Adds an action row to this sheet, turning it into an action sheet: the action sheet of iOS and the bottom sheet menu of Material.
public Button addDestructiveAction(String text, ActionListener l)Adds an action that deletes or discards something, drawn in the UIID ActionSheetDestructive (red in the native themes).
public void setCancelText(String text)Sets the text of the cancel button shown under the actions added with #addAction(String, ActionListener); null removes it, and the sheet still closes by swiping it down or tapping outside it.
public String getCancelText()The text of the cancel button of an action sheet, null for none.
public int getActionCount()The number of actions added with #addAction(String, ActionListener) and #addDestructiveAction(String, ActionListener).
public String getPosition()Gets the position where the Sheet is to be displayed.
public void setPosition(String position)Sets the position where the Sheet is to be displayed.
public void setPosition(String phonePosition, String tabletPosition)Sets the position where the Sheet is to be displayed.
public void back()Goes back to the parent sheet with a default (300ms) slide animation.
public void back(int duration)Goes back to the parent sheet with a slide animation of given duration.
public void setX(int x)Sets the Component x location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.
public void setY(int y)Sets the Component y location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.
public void setWidth(int width)Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.
public void setHeight(int height)Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.
public Sheet getParentSheet()Gets the parent sheet or null if there is none.
protected void initComponent()Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state
protected void deinitialize()Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
public boolean isAncestorSheetOf(Sheet sheet)Checks if the current sheet is an ancestor sheet of the given sheet.
public void addCloseListener(ActionListener l)Adds listener notified when the sheet is closed.
public void removeCloseListener(ActionListener l)Removes a close listener.
public void addBackListener(ActionListener l)Adds listener to be notified when user goes back to the parent.
public void removeBackListener(ActionListener l)Removes a back listener.

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, getOuterX, getInnerX, getY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, getOuterWidth, getInnerWidth, getHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

Sheet

public Sheet(Sheet parent, String title)
Creates a new sheet with the specified parent and title.

Parameters

parent Sheet
Optional parent sheet. If non-null, then this sheet will have a “back” button instead of a “close” button. The “back” button will return to the parent sheet.
title String
The title to display in the title bar of the sheet.

Sheet

public Sheet(Sheet parent, String title, String uiid)
Creates a new sheet with the specified parent and title.

Parameters

parent Sheet
Optional parent sheet. If non-null, then this sheet will have a “back” button instead of a “close” button. The “back” button will return to the parent sheet.
title String
The title to display in the title bar of the sheet.
uiid String
Optional UIID for the sheet. If non-null, then the Sheet’s uiid will be uiid, the title label’s UIID will be uiid + “Title”, the title bar’s UIID will be uiid + “TitleBar”, and the back/close button’s UIID will be uiid + “BackButton”.

Method details

setDetents

public void setDetents(float... fractions)

Lets the user drag the sheet between resting heights, as iOS sheet detents and Android’s half-expanded bottom sheet do. Dragging the title bar up grows the sheet to the next height, dragging it down shrinks it, and below the smallest one the sheet is dismissed as before. A flick moves one height in its direction.

The heights are fractions of the space the sheet is shown in – 0.5 is half the screen – and apply to a sheet at the bottom (BorderLayout#SOUTH, the default position); other positions keep their preferred size. The sheet opens at the first height unless #setDetentIndex(int) says otherwise.

Sheet sheet = new Sheet(null, "Directions");
sheet.setDetents(0.3f, 0.6f, 1f);
sheet.show();

Parameters

fractions float...
the heights, each above 0 and at most 1, in ascending order; none to go back to the preferred height

getDetents

public float[] getDetents()
The resting heights set with #setDetents(float...).

Returns

a copy of the fractions, or an empty array when none are set

getDetentIndex

public int getDetentIndex()
The detent the sheet rests at.

Returns

an index into #getDetents()

setDetentIndex

public void setDetentIndex(int index)
Moves the sheet to one of its detents, animating when it is showing.

Parameters

index int
an index into #getDetents()

addDetentListener

public void addDetentListener(ActionListener l)
Listens for the sheet settling at a different detent, by a drag or #setDetentIndex(int). The event’s source is the sheet.

Parameters

l ActionListener
the listener

removeDetentListener

public void removeDetentListener(ActionListener l)
Removes a detent listener.

Parameters

l ActionListener
the listener

calcPreferredSize

protected Dimension calcPreferredSize()
Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

Returns

the calculated preferred size based on component content

isSheetVisibleAt

public static boolean isSheetVisibleAt(int x, int y)

setTopLevelHost

public void setTopLevelHost(TopLevelContainer host)
Sets the top level this sheet appears on, which may be a com.codename1.ui.Window rather than the current Form.

Parameters

host TopLevelContainer
the top level to show on, or null to work it out

getTopLevelHost

public TopLevelContainer getTopLevelHost()
Returns the top level set with #setTopLevelHost(TopLevelContainer).

Returns

the explicit host, or null when none was set

getCurrentSheet

public static Sheet getCurrentSheet()
Gets the current sheet on the current form or null if no sheet is currently being displayed.

Returns

The current sheet or null.

getCurrentSheet

public static Sheet getCurrentSheet(TopLevelContainer top)
Gets the sheet currently showing on the given top level, or null.

Parameters

top TopLevelContainer
the top level to look on, may be null

Returns

The current sheet or null.

findContainingSheet

public static Sheet findContainingSheet(Component cmp)
Finds Sheet containing this component if it is currently part of a Sheet.

Parameters

cmp Component
The component to check.

Returns

The sheet containing the component, or null if it is not on a sheet.

isAllowClose

public boolean isAllowClose()
Checks whether the user is allowed to close this sheet.

Returns

True if user can close the sheet.

setAllowClose

public void setAllowClose(boolean allowClose)

Sets whether the user is able to close this sheet. Default is true. If you set this value to false, then there will be no close button, and pressing outside of the sheet will have no effect.

Child sheets will assume the settings of the parent. The back button will still work, but the top level sheet will not include a close button.

Parameters

allowClose boolean
True to allow user to close the sheet. False to prevent it.

isSwipeToDismissEnabled

public boolean isSwipeToDismissEnabled()
Checks whether this sheet can be dismissed by swiping it toward the edge of the screen (e.g. swiping down for a south-positioned sheet).

Returns

True if swipe-to-dismiss is enabled.

setSwipeToDismissEnabled

public void setSwipeToDismissEnabled(boolean swipeToDismissEnabled)
Enables or disables the swipe-to-dismiss gesture. When enabled (the default), a downward drag on the sheet’s title bar (or the corresponding direction for other positions) will close the sheet. The gesture is also subject to isAllowClose(); if allowClose is false the gesture is disabled regardless of this flag.

Parameters

swipeToDismissEnabled boolean
True to enable the swipe-to-dismiss gesture, false to disable it.

getContentPane

public Container getContentPane()
Gets the content pane of the sheet. All sheet content should be added to the content pane and not directly to the sheet.

Returns

The content pane.

hideBackButton

public void hideBackButton()
Hides the back button.

showBackButton

public void showBackButton()
Shows the back button.

getCommandsContainer

public Container getCommandsContainer()
Gets the container that is rendered on the top right bar of the sheet. Use this to add buttons and other content you wish to appear in the title bar. Best not to overload this with too many things.

getTitle

public String getTitle()
Gets the title text displayed in the default title label.

Returns

The sheet title text.

setTitle

public void setTitle(String title)

Sets the title text displayed in the default title label.

If a custom title component is currently installed via setTitleComponent(Component), this method still updates the default title label so that it will be shown if the title component is reset back to null.

Parameters

title String
The title text.

getTitleComponent

public Component getTitleComponent()
Gets the component currently used in the center of the title bar.

Returns

The current title component.

setTitleComponent

public void setTitleComponent(Component cmp)

Sets the title component rendered in the center of the title bar.

This allows for custom title layouts such as including an image above the title text. If null is passed, the default title label is restored.

Parameters

cmp Component
The component to use for the title area, or null to restore the default title label.

show

public void show()
Shows the sheet with the default (300ms) transition duration.

See also

showForResult

public <T> AsyncResource<T> showForResult()

Shows the sheet and returns an AsyncResource that will be completed when the sheet finishes – either with #finish(Object) carrying a chosen value, or with null when the sheet is dismissed via back/swipe.

Lets sheets be used as inline confirmation dialogs / pickers without wiring up addCloseListener + state-shared variables:

PickerSheet sheet = new PickerSheet();
sheet.<String>showForResult().ready(new SuccessCallback<String>() {
    public void onSuccess(String picked) {
        if (picked != null) handle(picked);
    }
});

The result type is supplied at the call site; use Sheet#finish(Object) internally to complete it. The cast is unchecked at runtime – pick a type you control inside the sheet.

Since 7.0

showForResult

public <T> AsyncResource<T> showForResult(int duration)

#showForResult with a custom slide duration.

Since 7.0

finish

public void finish(Object result)

Completes the result resource returned by #showForResult and dismisses the sheet. No-op (besides dismissal) if showForResult was not used to open this sheet.

Since 7.0

Parameters

result Object
the value to deliver to the resource subscriber. May be null, in which case subscribers see the same outcome as a user-initiated dismissal.

show

public void show(int duration)

Shows the sheet over the current form using a slide-up transition with given duration in milliseconds.

If another sheet is currently being shown, then this will replace that sheet, and use an appropriate slide animation to adjust the size.

Parameters

duration int
The duration of the slide transition in milliseconds.

See also

addAction

public Button addAction(String text, ActionListener l)

Adds an action row to this sheet, turning it into an action sheet: the action sheet of iOS and the bottom sheet menu of Material.

Sheet sheet = new Sheet(null, "Photo");
sheet.addAction("Share", e -> Log.p("Share"));
sheet.addDestructiveAction("Delete", e -> Log.p("Delete"));
sheet.show();

Picking an action closes the sheet and then calls its listener. The rows use the UIID ActionSheetItem (falling back to Button) inside an ActionSheetList container added to the content pane. Once a sheet has actions, #show() adds a cancel button under them (UIID ActionSheetCancel); #setCancelText(String) changes or removes it.

Parameters

text String
the label of the action
l ActionListener
called when it is picked; may be null

Returns

the button added for the action

addDestructiveAction

public Button addDestructiveAction(String text, ActionListener l)
Adds an action that deletes or discards something, drawn in the UIID ActionSheetDestructive (red in the native themes).

Parameters

text String
the label of the action
l ActionListener
called when it is picked; may be null

Returns

the button added for the action

setCancelText

public void setCancelText(String text)
Sets the text of the cancel button shown under the actions added with #addAction(String, ActionListener); null removes it, and the sheet still closes by swiping it down or tapping outside it.

Parameters

text String
the text, by default the theme’s localization of the key cancel (“Cancel”)

getCancelText

public String getCancelText()
The text of the cancel button of an action sheet, null for none.

Returns

the cancel text

getActionCount

public int getActionCount()
The number of actions added with #addAction(String, ActionListener) and #addDestructiveAction(String, ActionListener).

Returns

the action count, the cancel button not counted

getPosition

public String getPosition()
Gets the position where the Sheet is to be displayed. One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST. Default is BorderLayout#SOUTH.

setPosition

public void setPosition(String position)
Sets the position where the Sheet is to be displayed. One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST. Default is BorderLayout#SOUTH.

Parameters

position String
One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST.

setPosition

public void setPosition(String phonePosition, String tabletPosition)
Sets the position where the Sheet is to be displayed. One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST. Default is BorderLayout#SOUTH.

Parameters

phonePosition String
Position to use on a phone (i.e. non-tablet). One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST.
tabletPosition String
Position to use on a tablet and desktop. One of BorderLayout#CENTER, BorderLayout#NORTH, BorderLayout#SOUTH, BorderLayout#WEST, or BorderLayout#EAST.

back

public void back()
Goes back to the parent sheet with a default (300ms) slide animation. If there is no parent sheet, then this will close the sheet.

See also

back

public void back(int duration)
Goes back to the parent sheet with a slide animation of given duration. If there is no parent sheet, then this will close the sheet.

Parameters

duration int
Duration of the slide transition in milliseconds.

setX

public void setX(int x)
Sets the Component x location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.

Parameters

x int
the current x coordinate of the components origin

setY

public void setY(int y)
Sets the Component y location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.

Parameters

y int
the current y coordinate of the components origin

setWidth

public void setWidth(int width)

Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.

If a user wishes to affect the component size, setPreferredSize should be used.

Parameters

width int
the width of the component

setHeight

public void setHeight(int height)

Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.

If a user wishes to affect the component size, setPreferredSize should be used.

Parameters

height int
the height of the component

getParentSheet

public Sheet getParentSheet()
Gets the parent sheet or null if there is none.

Returns

The parent sheet or null.

initComponent

protected void initComponent()
Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state

deinitialize

protected void deinitialize()
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

isAncestorSheetOf

public boolean isAncestorSheetOf(Sheet sheet)
Checks if the current sheet is an ancestor sheet of the given sheet.

Parameters

sheet Sheet
The sheet to check

Returns

True if the current sheet is an ancestor of sheet.

addCloseListener

public void addCloseListener(ActionListener l)
Adds listener notified when the sheet is closed. This event is only fired when the sheet is closed without the possibility of being reopened. E.g. if a child sheet is opened (causing this sheet to be hidden), the close event won’t be fired until either that child sheet is hidden (without going back), or the sheet itself is hidden, or goes back.

removeCloseListener

public void removeCloseListener(ActionListener l)
Removes a close listener.

Parameters

l ActionListener
The close listener

addBackListener

public void addBackListener(ActionListener l)
Adds listener to be notified when user goes back to the parent. This is not fired if the sheet is simply closed. Only if the “back” button is pressed,

Parameters

l ActionListener
Listener

removeBackListener

public void removeBackListener(ActionListener l)
Removes a back listener.

Parameters

l ActionListener
The close listener