Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class StepFlow
ImplementsAnimation, Editable, Iterable<Component>, StyleListener
A multi-step flow: a checkout, a sign-up or a setup wizard. Each step has a
title, an optional subtitle and a body; a row of numbered markers shows
where the user is, and Back and Continue buttons move between the steps.
It is Flutter’s Stepper, Material’s stepper and the MUI Stepper.
TextField address = new TextField("", "Address");
StepFlow flow = new StepFlow()
.addStep("Shipping", "Where it goes", address)
.addStep("Payment", null, new Label("Card on file"))
.addStep("Review", null, new Label("Everything looks right"));
flow.setStepValidator((f, step) -> step != 0 || address.getText().length() > 0);
flow.addFinishListener(e -> Log.p("Order placed"));
Form form = new Form("Checkout", new BorderLayout());
form.add(BorderLayout.CENTER, flow);
form.show();Steps before the current one are done and show a check, the current one is
filled and later ones are faded. #setError(int, boolean) marks a step as
failed and #setStepEnabled(int, boolean) skips it. A validator runs before
the user leaves a step forwards; when it refuses, the step is marked as an
error and the flow stays where it is. Going back never validates.
By default the markers run across the top and the body of the current step
fills the space below them. new StepFlow(true) lays the steps out in a
column instead, with the current step’s body and buttons opening under its
title, the layout Flutter calls a vertical stepper.
For a read-only progress display with no bodies (order tracking, a
delivery status) use ActivityTimeline. The numeric Stepper control is
unrelated.
UIIDs: StepFlow for the whole component, StepFlowHeader for the row of
markers, StepFlowTitle and StepFlowSubtitle for a step’s texts,
StepFlowContent for the body, StepFlowNavigation for the button bar,
StepFlowBackButton and StepFlowNextButton for its buttons. The marker
colours follow the theme’s Slider colours unless StepFlowMarker is
styled; StepFlowMarkerError sets the error colour.
Nested types
interface StepFlow.StepValidator | Decides whether the user may leave a step forwards. |
Fields
public static final int DONE = 0 | The step’s position relative to the current one decides how it is drawn: before it is done. |
public static final int CURRENT = 1 | The step being shown. |
public static final int PENDING = 2 | A step after the current one. |
public static final int ERROR = 3 | A step marked as failed with #setError(int, boolean). |
public static final int DISABLED = 4 | A step turned off with #setStepEnabled(int, boolean). |
Constructors
public StepFlow() | An empty flow with its markers across the top. |
public StepFlow(boolean vertical) | An empty flow. |
Methods
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
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, calcPreferredSize, 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, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, 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, 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, deinitialize, initComponent, 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
From Iterable
Field details
DONE
public static final int DONE = 0CURRENT
public static final int CURRENT = 1PENDING
public static final int PENDING = 2ERROR
public static final int ERROR = 3#setError(int, boolean).DISABLED
public static final int DISABLED = 4#setStepEnabled(int, boolean).Constructor details
StepFlow
public StepFlow()StepFlow
public StepFlow(boolean vertical)Parameters
verticalboolean- true to stack the steps in a column, with the current step’s body under its title; false for markers across the top
Method details
initUnselectedStyle
protected void initUnselectedStyle(Style unselectedStyle)Parameters
unselectedStyleStyle- The unselected style.
isVertical
public boolean isVertical()Returns
addStep
public StepFlow addStep(String title, String subtitle, Component content)Parameters
titleString- the step’s title
subtitleString- a short line under the title, or null
contentComponent- the step’s body, or null for a step with no body
Returns
clearSteps
public void clearSteps()getStepCount
public int getStepCount()Returns
getCurrentStep
public int getCurrentStep()Returns
setCurrentStep
public void setCurrentStep(int index)#next(),
#back() and taps on the markers.Parameters
indexint- the step to show
getState
public int getState(int index)#DONE, #CURRENT, #PENDING, #ERROR or
#DISABLED.Parameters
indexint- the step’s index
Returns
setError
public void setError(int index, boolean error)Parameters
indexint- the step’s index
errorboolean- true to show the step as an error
setStepEnabled
public void setStepEnabled(int index, boolean enabled)#next() and #back() skip a disabled step,
and a tap on it does nothing.Parameters
indexint- the step’s index
enabledboolean- false to skip the step
isStepEnabled
public boolean isStepEnabled(int index)Parameters
indexint- the step’s index
Returns
getStepContent
public Component getStepContent(int index)Parameters
indexint- the step’s index
Returns
#addStep(String, String, Component)setStepValidator
public void setStepValidator(StepFlow.StepValidator validator)Parameters
validatorStepFlow.StepValidator- the validator, or null to allow every move
setTapToJump
public void setTapToJump(boolean tapToJump)Parameters
tapToJumpboolean- false to move only with the buttons
isTapToJump
public boolean isTapToJump()Returns
setAnimated
public void setAnimated(boolean animated)Parameters
animatedboolean- false to switch bodies at once
setButtonTexts
public void setButtonTexts(String back, String next, String finish)Parameters
backString- the Back button’s text
nextString- the text of the button that moves forwards
finishString- the text that button shows on the last step
getBackButton
public Button getBackButton()Returns
getNextButton
public Button getNextButton()Returns
addStepListener
public void addStepListener(ActionListener l)#getCurrentStep().Parameters
lActionListener- the listener
removeStepListener
public void removeStepListener(ActionListener l)Parameters
lActionListener- the listener
addFinishListener
public void addFinishListener(ActionListener l)Parameters
lActionListener- the listener
removeFinishListener
public void removeFinishListener(ActionListener l)Parameters
lActionListener- the listener
next
public boolean next()Returns
back
public boolean back()