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

public class StepFlow

  1. Object
  2. Component
  3. Container
  4. 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.StepValidatorDecides whether the user may leave a step forwards.

Fields

public static final int DONE = 0The step’s position relative to the current one decides how it is drawn: before it is done.
public static final int CURRENT = 1The step being shown.
public static final int PENDING = 2A step after the current one.
public static final int ERROR = 3A step marked as failed with #setError(int, boolean).
public static final int DISABLED = 4A 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

protected void initUnselectedStyle(Style unselectedStyle)Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.
public boolean isVertical()Whether the steps are stacked in a column.
public StepFlow addStep(String title, String subtitle, Component content)Adds a step at the end.
public void clearSteps()Removes every step.
public int getStepCount()The number of steps.
public int getCurrentStep()The index of the step being shown.
public void setCurrentStep(int index)Shows a step without running the validator.
public int getState(int index)How a step is drawn now: #DONE, #CURRENT, #PENDING, #ERROR or #DISABLED.
public void setError(int index, boolean error)Marks a step as failed, or clears the mark.
public void setStepEnabled(int index, boolean enabled)Turns a step on or off.
public boolean isStepEnabled(int index)Whether a step is on.
public Component getStepContent(int index)The body of a step.
public void setStepValidator(StepFlow.StepValidator validator)Sets the validator that runs before the user moves forwards.
public void setTapToJump(boolean tapToJump)Whether a tap on a step’s marker or title moves to it.
public boolean isTapToJump()Whether taps on the steps move to them.
public void setAnimated(boolean animated)Whether moving between steps slides the body.
public void setNavigationVisible(boolean visible)Shows or hides the Back and Continue buttons, for a flow driven from the application’s own buttons through #next() and #back().
public void setButtonTexts(String back, String next, String finish)Sets the button texts.
public Button getBackButton()The Back button, to restyle it or give it an icon.
public Button getNextButton()The Continue / Finish button.
public void addStepListener(ActionListener l)Listens for the current step changing.
public void removeStepListener(ActionListener l)Removes a step listener.
public void addFinishListener(ActionListener l)Listens for the user finishing the flow: Continue pressed on the last step after it validated.
public void removeFinishListener(ActionListener l)Removes a finish listener.
public boolean next()Moves to the next enabled step after validating the current one.
public boolean back()Moves to the previous enabled step, without validating.

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, 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

Field details

DONE

public static final int DONE = 0
The step’s position relative to the current one decides how it is drawn: before it is done.

CURRENT

public static final int CURRENT = 1
The step being shown.

PENDING

public static final int PENDING = 2
A step after the current one.

ERROR

public static final int ERROR = 3
A step marked as failed with #setError(int, boolean).

DISABLED

public static final int DISABLED = 4
A step turned off with #setStepEnabled(int, boolean).

Constructor details

StepFlow

public StepFlow()
An empty flow with its markers across the top.

StepFlow

public StepFlow(boolean vertical)
An empty flow.

Parameters

vertical boolean
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)
Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.

Parameters

unselectedStyle Style
The unselected style.

isVertical

public boolean isVertical()
Whether the steps are stacked in a column.

Returns

true for a vertical flow

addStep

public StepFlow addStep(String title, String subtitle, Component content)
Adds a step at the end. The first step added becomes the current one.

Parameters

title String
the step’s title
subtitle String
a short line under the title, or null
content Component
the step’s body, or null for a step with no body

Returns

this, for chaining

clearSteps

public void clearSteps()
Removes every step.

getStepCount

public int getStepCount()
The number of steps.

Returns

the step count

getCurrentStep

public int getCurrentStep()
The index of the step being shown.

Returns

the current step, or -1 when the flow is empty

setCurrentStep

public void setCurrentStep(int index)
Shows a step without running the validator. Use it to restore a flow or to move the user from code; the user’s own moves go through #next(), #back() and taps on the markers.

Parameters

index int
the step to show

getState

public int getState(int index)
How a step is drawn now: #DONE, #CURRENT, #PENDING, #ERROR or #DISABLED.

Parameters

index int
the step’s index

Returns

the step’s state

setError

public void setError(int index, boolean error)
Marks a step as failed, or clears the mark. A step the validator refused is marked automatically and cleared when it next passes.

Parameters

index int
the step’s index
error boolean
true to show the step as an error

setStepEnabled

public void setStepEnabled(int index, boolean enabled)
Turns a step on or off. #next() and #back() skip a disabled step, and a tap on it does nothing.

Parameters

index int
the step’s index
enabled boolean
false to skip the step

isStepEnabled

public boolean isStepEnabled(int index)
Whether a step is on.

Parameters

index int
the step’s index

Returns

false when the step is skipped

getStepContent

public Component getStepContent(int index)
The body of a step.

Parameters

index int
the step’s index

Returns

the component passed to #addStep(String, String, Component)

setStepValidator

public void setStepValidator(StepFlow.StepValidator validator)
Sets the validator that runs before the user moves forwards.

Parameters

validator StepFlow.StepValidator
the validator, or null to allow every move

setTapToJump

public void setTapToJump(boolean tapToJump)
Whether a tap on a step’s marker or title moves to it. Moving back is always allowed; moving forwards validates every step in between. On by default.

Parameters

tapToJump boolean
false to move only with the buttons

isTapToJump

public boolean isTapToJump()
Whether taps on the steps move to them.

Returns

true when a tap moves to the step

setAnimated

public void setAnimated(boolean animated)
Whether moving between steps slides the body. On by default.

Parameters

animated boolean
false to switch bodies at once

setNavigationVisible

public void setNavigationVisible(boolean visible)
Shows or hides the Back and Continue buttons, for a flow driven from the application’s own buttons through #next() and #back().

Parameters

visible boolean
false to hide the button bar

setButtonTexts

public void setButtonTexts(String back, String next, String finish)
Sets the button texts.

Parameters

back String
the Back button’s text
next String
the text of the button that moves forwards
finish String
the text that button shows on the last step

getBackButton

public Button getBackButton()
The Back button, to restyle it or give it an icon.

Returns

the Back button

getNextButton

public Button getNextButton()
The Continue / Finish button.

Returns

the button that moves forwards

addStepListener

public void addStepListener(ActionListener l)
Listens for the current step changing. The event’s source is this flow; read #getCurrentStep().

Parameters

l ActionListener
the listener

removeStepListener

public void removeStepListener(ActionListener l)
Removes a step listener.

Parameters

l ActionListener
the listener

addFinishListener

public void addFinishListener(ActionListener l)
Listens for the user finishing the flow: Continue pressed on the last step after it validated.

Parameters

l ActionListener
the listener

removeFinishListener

public void removeFinishListener(ActionListener l)
Removes a finish listener.

Parameters

l ActionListener
the listener

next

public boolean next()
Moves to the next enabled step after validating the current one. On the last step it validates and then notifies the finish listeners.

Returns

true if the flow moved on or finished

back

public boolean back()
Moves to the previous enabled step, without validating.

Returns

false when there is no earlier step