Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class KanbanBoard
- Object
- Component
- ScrollSurface
- KanbanBoard
ImplementsAnimation, Editable, StyleListener
A Kanban board: columns of cards, dragged from one stage to the next.
DefaultKanbanModel model = new DefaultKanbanModel();
model.addColumn(new KanbanColumn("todo", "To do"));
model.addColumn(new KanbanColumn("doing", "Doing").setWipLimit(3));
model.addColumn(new KanbanColumn("done", "Done"));
model.addCard("todo", new KanbanCard("c1", "Write the release notes").addTag("docs"));
Form form = new Form("Board", new BorderLayout());
KanbanBoard board = new KanbanBoard(model);
form.add(BorderLayout.CENTER, board);
form.show();The whole board scrolls as one surface, both ways, under column titles
that stay in view. A card is dragged with a mouse, or after a long press
with a finger, which leaves a plain drag free to scroll; the other cards
make room where it would land. Column titles are dragged the same way to
reorder the columns, and the mark at the end of a title folds the column
to a strip. With KanbanLanes in the model the board has swimlanes, each
under a title that folds it.
A column shows how many cards it holds, against its limit when it has
one, and is marked when it is over. A model that enforces its limits
(DefaultKanbanModel.setEnforceWipLimits) shows the refusal while the
card is still held over the column.
On a narrow screen setColumnSnap brings scrolling to rest on a column.
A KanbanCardFactory puts a component in each card; it is drawn with the
card, and a tap on it reaches it.
The row under the cards of a column adds a card, typed in place, and a
double tap renames one. Every edit is offered to the KanbanListeners
and then to the model, and with setUndoHistory can be undone. With a
keyboard, Delete removes the selected card, and with Control or Command,
C, X, V and D copy, cut, paste and duplicate it, Z undoes and Shift-Z
redoes.
Styling
The UIIDs are KanbanBoard, KanbanColumn, KanbanColumnHeader,
KanbanColumnOverLimit, KanbanCard, KanbanCardSelected,
KanbanCardTag, KanbanLane, KanbanAddCard and KanbanDropSlot. A
theme that defines none of them gets defaults that follow its light or
dark mode.
Constructors
public KanbanBoard() | An empty board backed by a new DefaultKanbanModel. |
public KanbanBoard(KanbanModel model) | A board showing model. |
Methods
public KanbanModel getModel() | The model shown. |
public void setModel(KanbanModel model) | Shows another model. |
public void modelChanged() | The model changed: the board is laid out again before it is next painted or asked where something is. |
public KanbanCardRenderer getCardRenderer() | Paints the cards. |
public void setCardRenderer(KanbanCardRenderer renderer) | Sets the renderer of the cards. |
public KanbanCardFactory getCardFactory() | Makes the components inside the cards, or null. |
public void setCardFactory(KanbanCardFactory cardFactory) | Puts a real component inside each card; null, the default, for cards that are only painted. |
public Component getCardComponent(KanbanCard card) | The component the factory made for a card, or null. |
public int getCardComponentHeight(KanbanCard card) | The height, in pixels, the component of a card takes at the bottom of it; 0 for a card without one. |
public void addKanbanListener(KanbanListener l) | Adds a listener. |
public void removeKanbanListener(KanbanListener l) | Removes a listener. |
public boolean isEditingEnabled() | True when the user can move, add, rename and remove cards. |
public void setEditingEnabled(boolean editable) | Lets the user edit the board, the default, or only look at it. |
public boolean isColumnReorderEnabled() | True when the columns can be dragged into another order. |
public void setColumnReorderEnabled(boolean columnReorder) | Lets the user drag a column by its title to another place; on by default. |
public boolean isInlineAdd() | True when every column ends in a row that adds a card. |
public void setInlineAdd(boolean inlineAdd) | Shows a row under the cards of each column that adds a card typed in place; on by default. |
public boolean isInlineEditing() | True when a double tap renames a card in place. |
public void setInlineEditing(boolean inlineEditing) | Makes a double tap on a card rename it in place, the default, or only tell the listeners the card was opened. |
public boolean isColumnSnap() | True when scrolling comes to rest on a column. |
public void setColumnSnap(boolean columnSnap) | Makes scrolling across the board come to rest with a column at its leading edge, so a narrow screen shows one whole column at a time and not the halves of two. |
public String getAddCardText() | The text of the row that adds a card. |
public void setAddCardText(String addCardText) | Sets the text of the row that adds a card, for another language. |
public float getColumnWidth() | The width of a column, in millimetres. |
public void setColumnWidth(float millimetres) | Sets the width of a column, in millimetres; 42 by default. |
public KanbanCard getSelectedCard() | The selected card, or null. |
public void select(KanbanCard card) | Selects a card, or with null none. |
public void scrollToColumn(KanbanColumn column) | Scrolls so a column is at the leading edge of the view. |
public void scrollToCard(KanbanCard card) | Scrolls so a card is in view. |
public UndoHistory getUndoHistory() | The history edits are recorded in, or null. |
public void setUndoHistory(UndoHistory undoHistory) | Records every edit the user makes in a history, so it can be undone. |
public boolean undo() | Takes back the last edit in the history. |
public boolean redo() | Makes the last undone edit again. |
public boolean moveCard(KanbanCard card, KanbanColumn column, KanbanLane lane, int index) | Moves a card to an index of a cell, as a drop there does: offered to the listeners, then to the model, and recorded for undo. |
public boolean moveColumn(KanbanColumn column, int index) | Moves a column to an index, counted without it, as dragging its title does. |
public KanbanCard addCard(KanbanColumn column, KanbanLane lane, String title) | Adds a card with a title at the end of a cell, as typing it into the row under the column does: offered to the listeners, then to the model, recorded for undo and selected. |
public boolean renameCard(KanbanCard card, String title) | Gives a card another title, as renaming it in place does. |
public boolean removeCard(KanbanCard card) | Removes a card, as Delete on it does. |
public boolean duplicateSelection() | Adds a copy of the selected card under it. |
public void setUserDataCodec(KanbanJson.UserDataCodec codec) | Writes the user data of a copied card to the clipboard and reads it back on paste; without one, a pasted card has no user data. |
public boolean copySelection() | Puts the selected card on the clipboard, as JSON. |
public boolean cutSelection() | Copies the selected card and removes it. |
public boolean paste() | Adds the card on the clipboard under the selected card, or at the end of the first column when none is selected. |
public boolean isEditing() | True while a title is being typed in place. |
public void startCardEdit(KanbanCard card) | Renames a card in place, in a text field over it; the title goes to renameCard when editing ends. |
public void startAddCard(KanbanColumn column, KanbanLane lane) | Opens the row that adds a card to a cell for typing; the card is added by addCard when editing ends with a title in it. |
public void finishEditing() | Ends the typing of a title and applies it. |
public int[] getCardBounds(KanbanCard card) | The rectangle of a card in the board’s own coordinates, as it is laid out now, or null when it is not shown. |
public int[] getColumnHeaderBounds(KanbanColumn column) | The rectangle of a column’s title in the board’s own coordinates, or null for a column that is not in the model. |
public Image toImage(int maxWidth, int maxHeight) | Paints the whole board, every column and card of it, into a new image no larger than the given size, without the selection. |
protected void layoutSurface(int width, int height) | Lays the surface out for a size: sets the header sizes and whatever the content’s size depends on. |
protected int getContentWidth() | The width of what scrolls, in pixels, without the left header. |
protected int getContentHeight() | The height of what scrolls, in pixels, without the top header. |
protected void paintContent(Graphics g, int x, int y) | Paints what scrolls. |
protected void paintTopHeader(Graphics g, int x, int y) | Paints the pinned top row. |
protected void paintOverlay(Graphics g, int x, int y) | Paints over everything, in the component’s own bounds, whose top left is x, y. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
protected void scrollChanged() | The scroll position changed. |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
protected void pressStarted(int x, int y) | The pointer went down at a point, in the component’s coordinates. |
protected boolean editStarted(int x, int y, ScrollSurface.EditTrigger trigger) | Asked when a drag or a long press begins, at the point where the pointer went down, in the component’s coordinates. |
protected void editMoved(int x, int y) | The pointer of an edit moved, or the surface scrolled under it. |
protected void editEnded(boolean committed) | The edit is over. |
protected void tapped(int x, int y, boolean doubleTap) | A tap that was not a drag or a long press. |
protected boolean animateSurface() | Advances the view’s own motion. |
protected void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
Inherited nested types
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 ScrollSurface
paintLeftHeader, paintCorner, setHeaderSize, getHeaderWidth, getHeaderHeight, isEditAutoScroll, longPressed, zoomBy, setDragEdits, isDragEdits, cancelEdit, isEditInProgress, isBounded, setBounded, getBodyWidth, getBodyHeight, getMaxOffsetX, getMaxOffsetY, getOffsetX, getOffsetY, scrollTo, setOffsets, refreshLayout, stopFling, currentTime, setAnimationTime, hoverAt, hoverGone, setHoverTarget, setHoverTooltip, getFadingHoverTarget, getHoverTarget, hasHoverFeedback, getHoverLevel, getLiftLevel, startSettle, applySettle, pointerHover, setHovered, initComponent, requestAnimation, animate, paint, getPageGrid, paintPage, isPrinting, saveZoomState, restoreZoomState, getPageStep, pointerPressed, pointerDragged, longPointerPress, mouseWheel, pinch, pinchReleased, shouldBlockSideSwipe
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, initLaf, getUIManager, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, clearClientProperties, 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, fireClicked, isSelectableInteraction, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, isScrollableX, isScrollableY, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, getBottomGap, getSideGap, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyReleased, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, dragInitiated, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, 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, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, paramString, refreshTheme, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, cancelRepaints, 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
KanbanBoard
public KanbanBoard()DefaultKanbanModel.KanbanBoard
public KanbanBoard(KanbanModel model)model.Method details
getModel
public KanbanModel getModel()setModel
public void setModel(KanbanModel model)modelChanged
public void modelChanged()The model changed: the board is laid out again before it is next painted or asked where something is. Called by the model’s listener, and by an application that changed a card behind the model’s back, such as its tags.
Nothing is measured here, so filling a model a card at a time while a board shows it costs one layout and not one per card.
getCardRenderer
public KanbanCardRenderer getCardRenderer()setCardRenderer
public void setCardRenderer(KanbanCardRenderer renderer)getCardFactory
public KanbanCardFactory getCardFactory()setCardFactory
public void setCardFactory(KanbanCardFactory cardFactory)getCardComponent
public Component getCardComponent(KanbanCard card)getCardComponentHeight
public int getCardComponentHeight(KanbanCard card)addKanbanListener
public void addKanbanListener(KanbanListener l)removeKanbanListener
public void removeKanbanListener(KanbanListener l)isEditingEnabled
public boolean isEditingEnabled()setEditingEnabled
public void setEditingEnabled(boolean editable)isColumnReorderEnabled
public boolean isColumnReorderEnabled()setColumnReorderEnabled
public void setColumnReorderEnabled(boolean columnReorder)isInlineAdd
public boolean isInlineAdd()setInlineAdd
public void setInlineAdd(boolean inlineAdd)isInlineEditing
public boolean isInlineEditing()setInlineEditing
public void setInlineEditing(boolean inlineEditing)isColumnSnap
public boolean isColumnSnap()setColumnSnap
public void setColumnSnap(boolean columnSnap)getAddCardText
public String getAddCardText()setAddCardText
public void setAddCardText(String addCardText)getColumnWidth
public float getColumnWidth()setColumnWidth
public void setColumnWidth(float millimetres)getSelectedCard
public KanbanCard getSelectedCard()select
public void select(KanbanCard card)scrollToColumn
public void scrollToColumn(KanbanColumn column)scrollToCard
public void scrollToCard(KanbanCard card)getUndoHistory
public UndoHistory getUndoHistory()setUndoHistory
public void setUndoHistory(UndoHistory undoHistory)UndoHistory.getGlobal(), by default; null
records nothing. An undone or redone step brings the board back into
view (ComponentEdit). Changes the application makes to the model directly are not
recorded.undo
public boolean undo()Returns
redo
public boolean redo()Returns
moveCard
public boolean moveCard(KanbanCard card, KanbanColumn column, KanbanLane lane, int index)lane is
null on a board without lanes. The index counts the cell without the
card.Returns
moveColumn
public boolean moveColumn(KanbanColumn column, int index)Returns
addCard
public KanbanCard addCard(KanbanColumn column, KanbanLane lane, String title)lane is null on a board
without lanes.Returns
renameCard
public boolean renameCard(KanbanCard card, String title)Returns
removeCard
public boolean removeCard(KanbanCard card)Returns
duplicateSelection
public boolean duplicateSelection()Returns
setUserDataCodec
public void setUserDataCodec(KanbanJson.UserDataCodec codec)copySelection
public boolean copySelection()Returns
cutSelection
public boolean cutSelection()Returns
paste
public boolean paste()Returns
isEditing
public boolean isEditing()Returns
startCardEdit
public void startCardEdit(KanbanCard card)renameCard when editing ends.startAddCard
public void startAddCard(KanbanColumn column, KanbanLane lane)addCard when editing ends with a title in it.finishEditing
public void finishEditing()getCardBounds
public int[] getCardBounds(KanbanCard card)getColumnHeaderBounds
public int[] getColumnHeaderBounds(KanbanColumn column)toImage
public Image toImage(int maxWidth, int maxHeight)layoutSurface
protected void layoutSurface(int width, int height)getContentWidth
protected int getContentWidth()getContentHeight
protected int getContentHeight()paintContent
protected void paintContent(Graphics g, int x, int y)x and y are where the content’s own origin is
on screen, which is off screen once it has scrolled. The graphics is
clipped to the content region.paintTopHeader
protected void paintTopHeader(Graphics g, int x, int y)x is where the content’s origin is; y
is the top of the row.paintOverlay
protected void paintOverlay(Graphics g, int x, int y)x, y. Not painted on a printed page: it is for what a gesture in
progress shows.calcPreferredSize
protected Dimension calcPreferredSize()Returns
scrollChanged
protected void scrollChanged()pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pressStarted
protected void pressStarted(int x, int y)editStarted
protected boolean editStarted(int x, int y, ScrollSurface.EditTrigger trigger)Parameters
xint- Not documented.
yint- Not documented.
triggerScrollSurface.EditTrigger- what kind of gesture it is
Returns
editMoved
protected void editMoved(int x, int y)editEnded
protected void editEnded(boolean committed)committed is false when it was cancelled: by
cancelEdit, a second finger, or the surface leaving the form.tapped
protected void tapped(int x, int y, boolean doubleTap)animateSurface
protected boolean animateSurface()requestAnimation to start the frames.Returns
deinitialize
protected void deinitialize()keyPressed
public void keyPressed(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.