public class FloatingActionButton extends Button
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:
The button can also nest sub actions
STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR
Modifier | Constructor and Description |
---|---|
protected |
FloatingActionButton(char icon,
String text,
float size)
Constructor
|
protected |
FloatingActionButton(char icon,
String text,
String uiid,
float size)
Constructor
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
static FloatingActionButton |
createBadge(String text)
Creates a text badge
|
static FloatingActionButton |
createFAB(char icon)
a factory method to create a FloatingActionButton.
|
static FloatingActionButton |
createFAB(char icon,
String uiid)
a factory method to create a FloatingActionButton.
|
protected Container |
createPopupContent(List<FloatingActionButton> fabs)
Creates the popup content container to display on the dialog.
|
FloatingActionButton |
createSubFAB(char icon,
String text)
Adds a sub FAB to the FloatingActionButton instance.
|
protected void |
fireActionEvent(int x,
int y)
Allows subclasses to override action event behavior
|
String |
getFloatingActionTextUIID() |
static float |
getIconDefaultSize()
The default icon size for the fab icon in millimeters
|
static boolean |
isAutoSizing()
The FloatingActionButton tries to size/pad itself automatically but
this means that manual padding is ignored.
|
void |
released(int x,
int y)
Invoked to change the state of the button to the released state
|
static void |
setAutoSizing(boolean aAutoSizing)
The FloatingActionButton tries to size/pad itself automatically but
this means that manual padding is ignored.
|
void |
setFloatingActionTextUIID(String floatingActionTextUIID) |
static void |
setIconDefaultSize(float aFabDefaultSize)
The default icon size for the fab icon in millimeters
|
void |
setText(String text)
Overriden to implement the caps mode
Button.setCapsText(boolean)
Sets the Label text |
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.
|
protected void |
showPopupDialog(Dialog dialog)
Shows the popup Dialog with the sub FABs.
|
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
|
void |
unbind()
Removes the floating action button from its parent
|
addActionListener, addStateChangeListener, animate, bindStateTo, dragInitiated, fireClicked, getActionListeners, getBorder, getCommand, getDisabledIcon, getIconFromState, getListeners, getPressedIcon, getReleaseRadius, getRolloverIcon, getRolloverPressedIcon, getState, isAutoRelease, isButtonRippleEffectDefault, isCapsText, isCapsTextDefault, isOppositeSide, isSelectableInteraction, isSelected, isToggle, keyPressed, keyReleased, keyRepeated, paint, pointerHover, pointerHoverReleased, pointerPressed, pointerReleased, pressed, released, removeActionListener, removeStateChangeListener, resetFocusable, setAlignment, setAutoRelease, setButtonRippleEffectDefault, setCapsText, setCapsTextDefault, setCommand, setDisabledIcon, setPressedIcon, setReleased, setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setToggle, unbindStateFrom
bindProperty, getAlignment, getBadgeStyleComponent, getBadgeText, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getDefaultGap, getFontIcon, getFontIconSize, getGap, getIcon, getIconFont, getIconStyleComponent, getIconUIID, getMask, getMaskedIcon, getMaskName, getMaterialIcon, getMaterialIconSize, getMaxAutoSize, getMinAutoSize, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getShiftMillimeters, getShiftMillimetersF, getShiftText, getStringWidth, getText, getTextPosition, getTextSelectionSupport, getVerticalAlignment, initLaf, initUnselectedStyle, isAutoSizeMode, isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank, isTextSelectionEnabled, isTickerEnabled, isTickerRunning, laidOut, paramString, refreshTheme, setAutoSizeMode, setBadgeText, setBadgeUIID, setBoundPropertyValue, setDefaultGap, setDefaultTickerEnabled, setEndsWith3Points, setFontIcon, setFontIcon, setFontIcon, setGap, setIcon, setIconUIID, setLegacyRenderer, setMask, setMaskName, setMaterialIcon, setMaterialIcon, setMaxAutoSize, setMinAutoSize, setPropertyValue, setShiftMillimeters, setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank, setTextPosition, setTextSelectionEnabled, setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, toImage, toString, updateNativeOverlay, visibleBoundsContains
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getGap, getIcon, getIconStyleComponent, getIconUIID, getTextPosition, setFontIcon, setGap, setIcon, setIconUIID, setMaterialIcon, setTextPosition
protected FloatingActionButton(char icon, String text, float size)
icon
- one of the FontImage.MATERIAL_* constantstext
- the text of the sub FloatingActionButtonsize
- the size in millimeterspublic static float getIconDefaultSize()
public static void setIconDefaultSize(float aFabDefaultSize)
aFabDefaultSize
- the fabDefaultSize to setpublic static boolean isAutoSizing()
public static void setAutoSizing(boolean aAutoSizing)
aAutoSizing
- the autoSizing to setpublic void setUIID(String id)
public void styleChanged(String propertyName, Style source)
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.
styleChanged
in interface StyleListener
styleChanged
in class Label
propertyName
- the property name that was changedsource
- The changed Style objectpublic static FloatingActionButton createBadge(String text)
text
- the text of the badgepublic static FloatingActionButton createFAB(char icon)
icon
- one of the FontImage.MATERIAL_* constantspublic static FloatingActionButton createFAB(char icon, String uiid)
icon
- one of the FontImage.MATERIAL_* constantsuiid
- the uiid for the fabpublic FloatingActionButton createSubFAB(char icon, String text)
icon
- one of the FontImage.MATERIAL_* constantstext
- the text of the sub FloatingActionButtonprotected Dimension calcPreferredSize()
Button
calcPreferredSize
in class Button
public Container bindFabToContainer(Component cnt)
cnt
- the Container to add the FAB topublic Container bindFabToContainer(Component cnt, int orientation, int valign)
cnt
- the Container to add the FAB toorientation
- one of Component.RIGHT/LEFT/CENTERvalign
- one of Component.TOP/BOTTOM/CENTERpublic void unbind()
public void setText(String text)
Button
Button.setCapsText(boolean)
Sets the Label textsetText
in interface TextHolder
setText
in class Button
text
- the string that the label presents.protected void fireActionEvent(int x, int y)
Button
fireActionEvent
in class Button
x
- the x position of the click if applicable (can be 0 or -1 otherwise)y
- the y position of the click if applicable (can be 0 or -1 otherwise)public void released(int x, int y)
Button
protected Container createPopupContent(List<FloatingActionButton> fabs)
fabs
- List of sub FloatingActionButtonprotected void showPopupDialog(Dialog dialog)
dialog
- the Dialog with all sub FAB's Componentspublic String getFloatingActionTextUIID()
public void setFloatingActionTextUIID(String floatingActionTextUIID)
floatingActionTextUIID
- the floatingActionTextUIID to set