public class FloatingActionButton
ImplementsActionSource<ActionEvent>, Animation, Editable, IconHolder, ReleasableComponent, SelectableIconHolder, StyleListener, TextHolder
Floating action buttons are a material design element used to promote a special action in a Form. They are represented as a floating circle with a flat icon floating above the UI typically in the bottom right area.
Simple use cases include just the button as a standalone:
FloatingActionButton fab = FloatingActionButton.createFAB(FontImage.MATERIAL_ADD);
fab.addActionListener(e -> ToastBar.showErrorMessage("Not implemented yet..."));
fab.bindFabToContainer(hi.getContentPane());
The button can also nest sub actions
FloatingActionButton fab = FloatingActionButton.createFAB(FontImage.MATERIAL_ADD);
fab.createSubFAB(FontImage.MATERIAL_PEOPLE, "");
fab.createSubFAB(FontImage.MATERIAL_IMPORT_CONTACTS, "");
fab.bindFabToContainer(hi.getContentPane());
Constructors
protected FloatingActionButton(char icon, String text, float size) | Constructor |
protected FloatingActionButton(char icon, String text, String uiid, float size) | Constructor |
Methods
public static float getIconDefaultSize() | The default icon size for the fab icon in millimeters |
public static void setIconDefaultSize(float aFabDefaultSize) | The default icon size for the fab icon in millimeters |
public static boolean isAutoSizing() | The FloatingActionButton tries to size/pad itself automatically but this means that manual padding is ignored. |
public static void setAutoSizing(boolean aAutoSizing) | The FloatingActionButton tries to size/pad itself automatically but this means that manual padding is ignored. |
public static FloatingActionButton createBadge(String text) | Creates a text badge |
public static FloatingActionButton createFAB(char icon) | a factory method to create a FloatingActionButton. |
public static FloatingActionButton createFAB(char icon, String uiid) | a factory method to create a FloatingActionButton. |
public void setUIID(String id) | Overriden to update the icon Overriden to workaround issue with caps text and different UIID’s This method sets the Component the Unique identifier. |
public void styleChanged(String propertyName, Style source) | We override this method to track style changes to the background color and map them to the border |
public FloatingActionButton createSubFAB(char icon, String text) | Adds a sub FAB to the FloatingActionButton instance. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
public Container bindFabToContainer(Component cnt) | This is a utility method to bind the FAB to a given Container, it will return a new container to add or will use the layered pane if the container is a content pane. |
public Container bindFabToContainer(Component cnt, int orientation, int valign) | This is a utility method to bind the FAB to a given Container, it will return a new container to add or will use the layered pane if the container is a content pane. |
public void unbind() | Removes the floating action button from its parent |
public void setText(String text) | Overriden to implement the caps mode #setCapsText(boolean) Sets the Label text |
protected void fireActionEvent(int x, int y) | Allows subclasses to override action event behavior for pointer coordinates. |
public void released(int x, int y) | Invoked to change the state of the button to the released state |
protected Container createPopupContent(List<FloatingActionButton> fabs) | Creates the popup content container to display on the dialog. |
protected void showPopupDialog(Dialog dialog) | Shows the popup Dialog with the sub FABs. |
public String getFloatingActionTextUIID() | |
public void setFloatingActionTextUIID(String floatingActionTextUIID) |
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 Button
isCapsTextDefault, setCapsTextDefault, isButtonRippleEffectDefault, setButtonRippleEffectDefault, bindStateTo, unbindStateFrom, resetFocusable, getState, setReleased, getPressedIcon, setPressedIcon, getRolloverPressedIcon, setRolloverPressedIcon, getDisabledIcon, setDisabledIcon, getRolloverIcon, setRolloverIcon, addStateChangeListener, removeStateChangeListener, addActionListener, removeActionListener, getActionListeners, getListeners, getIconFromState, pressed, released, keyPressed, keyReleased, keyRepeated, fireClicked, isSelectableInteraction, pointerHover, pointerHoverReleased, pointerPressed, pointerReleased, dragInitiated, getBorder, getCommand, setCommand, isSelected, setAlignment, isToggle, setToggle, animate, isOppositeSide, getReleaseRadius, setReleaseRadius, isAutoRelease, setAutoRelease, paint, isCapsText, setCapsText
From Label
getDefaultGap, setDefaultGap, isDefaultTickerEnabled, setDefaultTickerEnabled, laidOut, getBadgeText, setBadgeText, setBadgeUIID, getBadgeStyleComponent, getIconStyleComponent, setFontIcon, setMaterialIcon, setFontIcon, getMaterialIcon, setMaterialIcon, getFontIcon, setFontIcon, getMaterialIconSize, getFontIconSize, getIconFont, getBaselineResizeBehavior, getBaseline, refreshTheme, initLaf, getText, getIcon, setIcon, getVerticalAlignment, setVerticalAlignment, getAlignment, getTextPosition, setTextPosition, getGap, setGap, paramString, getMaxAutoSize, setMaxAutoSize, getMinAutoSize, setMinAutoSize, getShiftText, setShiftText, shouldTickerStart, startTicker, startTicker, stopTicker, isTickerRunning, isTickerEnabled, setTickerEnabled, isEndsWith3Points, setEndsWith3Points, getMask, setMask, getMaskName, setMaskName, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, getMaskedIcon, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, isShouldLocalize, setShouldLocalize, getShiftMillimeters, setShiftMillimeters, setShiftMillimeters, getShiftMillimetersF, isShowEvenIfBlank, setShowEvenIfBlank, getStringWidth, isLegacyRenderer, setLegacyRenderer, initUnselectedStyle, isAutoSizeMode, setAutoSizeMode, isTextSelectionEnabled, setTextSelectionEnabled, getTextSelectionSupport, getIconUIID, setIconUIID
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, 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, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, 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, 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, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, stopScrollMomentum, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, 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, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, deinitialize, initComponent, isInitialized, setInitialized, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, 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, cancelRepaints, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Constructor details
FloatingActionButton
protected FloatingActionButton(char icon, String text, float size)Parameters
iconchar- one of the FontImage.MATERIAL_* constants
textString- the text of the sub FloatingActionButton
sizefloat- the size in millimeters
FloatingActionButton
protected FloatingActionButton(char icon, String text, String uiid, float size)Parameters
iconchar- one of the FontImage.MATERIAL_* constants
textString- the text of the sub FloatingActionButton
uiidString- the uiid of the FAB
sizefloat- the size in millimeters
Method details
getIconDefaultSize
public static float getIconDefaultSize()Returns
setIconDefaultSize
public static void setIconDefaultSize(float aFabDefaultSize)Parameters
aFabDefaultSizefloat- the fabDefaultSize to set
isAutoSizing
public static boolean isAutoSizing()Returns
setAutoSizing
public static void setAutoSizing(boolean aAutoSizing)Parameters
aAutoSizingboolean- the autoSizing to set
createBadge
public static FloatingActionButton createBadge(String text)Parameters
textString- the text of the badge
Returns
createFAB
public static FloatingActionButton createFAB(char icon)Parameters
iconchar- one of the FontImage.MATERIAL_* constants
Returns
createFAB
public static FloatingActionButton createFAB(char icon, String uiid)Parameters
iconchar- one of the FontImage.MATERIAL_* constants
uiidString- the uiid for the fab
Returns
setUIID
public void setUIID(String id)Parameters
idString- UIID unique identifier for component type
styleChanged
public void styleChanged(String propertyName, Style source)We override this method to track style changes to the background color and map them to the border
Invoked to indicate a change in a propertyName of a Style
NOTE By default this will trigger a call to Container#revalidate() on the parent
container, which is expensive. You can disable this behavior by calling CN.setProperty("Component.revalidateOnStyleChange", "false").
The intention is to change this behavior so that the default is to “not” revalidate on style change, so we encourage you to
set this to “false” to ensure for future compatibility.
Parameters
propertyNameString- the property name that was changed
sourceStyle- The changed Style object
createSubFAB
public FloatingActionButton createSubFAB(char icon, String text)Parameters
iconchar- one of the FontImage.MATERIAL_* constants
textString- the text of the sub FloatingActionButton
Returns
calcPreferredSize
protected Dimension calcPreferredSize()Returns
bindFabToContainer
public Container bindFabToContainer(Component cnt)Parameters
cntComponent- the Container to add the FAB to
Returns
bindFabToContainer
public Container bindFabToContainer(Component cnt, int orientation, int valign)Parameters
cntComponent- the Container to add the FAB to
orientationint- one of Component.RIGHT/LEFT/CENTER
valignint- one of Component.TOP/BOTTOM/CENTER
Returns
unbind
public void unbind()setText
public void setText(String text)#setCapsText(boolean)
Sets the Label textParameters
textString- the string that the label presents.
fireActionEvent
protected void fireActionEvent(int x, int y)Parameters
xint- the x position of the click if applicable (can be 0 or -1 otherwise)
yint- the y position of the click if applicable (can be 0 or -1 otherwise)
released
public void released(int x, int y)Parameters
xint- the x position if a touch event triggered this, -1 if this isn’t relevant
yint- the y position if a touch event triggered this, -1 if this isn’t relevant
createPopupContent
protected Container createPopupContent(List<FloatingActionButton> fabs)Parameters
fabsList<FloatingActionButton>- List of sub FloatingActionButton
Returns
showPopupDialog
protected void showPopupDialog(Dialog dialog)Parameters
dialogDialog- the Dialog with all sub FAB’s Components
getFloatingActionTextUIID
public String getFloatingActionTextUIID()Returns
setFloatingActionTextUIID
public void setFloatingActionTextUIID(String floatingActionTextUIID)Parameters
floatingActionTextUIIDString- the floatingActionTextUIID to set