# Class FloatingActionButton

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Label
com.codename1.ui.Button
com.codename1.components.FloatingActionButton

All Implemented Interfaces:
  `Animation, Editable, ActionSource<ActionEvent>, StyleListener, IconHolder, ReleasableComponent, SelectableIconHolder, TextHolder`

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:

    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());

- ## Field Summary

  ### Fields inherited from class Button

  `STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER`

  ### Fields inherited from class Component

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

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FloatingActionButton(char icon, String text, float size)`
  Constructor
  `protected`
  `FloatingActionButton(char icon, String text, String uiid, float size)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  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 for pointer coordinates.
  `String`
  `getFloatingActionTextUIID()`

  ###### Returns

  `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)`

  ###### Parameters

  `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 `#setCapsText(boolean)` Overriden to implement the caps mode `#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
  `void`
  `unbind()`
  Removes the floating action button from its parent

  ### Methods inherited from class Button

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

  ### Methods inherited from class Label

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

  ### Methods inherited from class Component

  `accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addNativeDragOverListener, addNativeDropListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStylusListener, announceForAccessibility, blocksSideSwipe, calcScrollSize, canAcceptNativeDrop, cancelRepaints, clearClientProperties, consumesRawTextInput, contains, containsOrOwns, createNativeDragOperation, createStyleAnimation, deinitialize, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAcceptedDropActions, getAcceptedDropMimeTypes, getAccessibilityNode, getAccessibilityText, 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, getNativeDragOperation, 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, getSemantics, getSideGap, getStyle, getTabIndex, getTensileLength, getTooltip, getTopLevelContainer, 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, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isNativeDragSource, isNativeDropTarget, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, longKeyPress, longPointerPress, mouseWheel, nativeDragEnter, nativeDragExit, nativeDragOver, nativeDrop, onScrollX, onScrollY, onSetFocusable, 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, registerForAnimation, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removeNativeDragOverListener, removeNativeDropListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStylusListener, repaint, repaint, requestFocus, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAcceptedDropActions, setAcceptedDropMimeTypes, setAccessibilityText, 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, setHorizontalScrollBounds, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNativeDragOperation, setNativeDragSource, setNativeDropTarget, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPullToRefresh, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stopScrollMomentum, stripMarginAndPadding, toImage, toString, updateNativeOverlay, visibleBoundsContains`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface IconHolder

  `getGap, getIcon, getIconStyleComponent, getIconUIID, getTextPosition, setFontIcon, setGap, setIcon, setIconUIID, setMaterialIcon, setTextPosition`

- ## Constructor Details

  - ### FloatingActionButton

    protected FloatingActionButton(char icon, String text, float size)

    Constructor

    ###### Parameters

    - `icon`: one of the FontImage.MATERIAL_* constants

    - `text`: the text of the sub FloatingActionButton

    - `size`: the size in millimeters

  - ### FloatingActionButton

    protected FloatingActionButton(char icon, String text, String uiid, float size)

    Constructor

    ###### Parameters

    - `icon`: one of the FontImage.MATERIAL_* constants

    - `text`: the text of the sub FloatingActionButton

    - `uiid`: the uiid of the FAB

    - `size`: the size in millimeters

- ## Method Details

  - ### getIconDefaultSize

    public static float getIconDefaultSize()

    The default icon size for the fab icon in millimeters

    ###### Returns

    the fabDefaultSize

  - ### setIconDefaultSize

    public static void setIconDefaultSize(float aFabDefaultSize)

    The default icon size for the fab icon in millimeters

    ###### Parameters

    - `aFabDefaultSize`: the fabDefaultSize to set

  - ### isAutoSizing

    public static boolean isAutoSizing()

    The FloatingActionButton tries to size/pad itself automatically but this means that manual padding is ignored. Setting this to false disables that behavior

    ###### Returns

    the autoSizing

  - ### setAutoSizing

    public static void setAutoSizing(boolean aAutoSizing)

    The FloatingActionButton tries to size/pad itself automatically but this means that manual padding is ignored. Setting this to false disables that behavior

    ###### Parameters

    - `aAutoSizing`: the autoSizing to set

  - ### createBadge

    public static FloatingActionButton createBadge(String text)

    Creates a text badge

    ###### Parameters

    - `text`: the text of the badge

    ###### Returns

    a badge component

  - ### createFAB

    public static FloatingActionButton createFAB(char icon)

    a factory method to create a FloatingActionButton.

    ###### Parameters

    - `icon`: one of the FontImage.MATERIAL_* constants

    ###### Returns

    a FloatingActionButton instance

  - ### createFAB

    public static FloatingActionButton createFAB(char icon, String uiid)

    a factory method to create a FloatingActionButton.

    ###### Parameters

    - `icon`: one of the FontImage.MATERIAL_* constants

    - `uiid`: the uiid for the fab

    ###### Returns

    a FloatingActionButton instance

  - ### setUIID

    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. This method should be used before a component has been initialized

    ###### Parameters

    - `id`: UIID unique identifier for component type
    Overrides:
      `setUIID` in class `Button`

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

    - `propertyName`: the property name that was changed

    - `source`: The changed Style object

    Specified by:
      `styleChanged` in interface `StyleListener`
    Overrides:
      `styleChanged` in class `Label`

  - ### createSubFAB

    public FloatingActionButton createSubFAB(char icon, String text)

    Adds a sub FAB to the FloatingActionButton instance. Once pressed all its sub FAB's are displayed.

    ###### Parameters

    - `icon`: one of the FontImage.MATERIAL_* constants

    - `text`: the text of the sub FloatingActionButton

    ###### Returns

    a FloatingActionButton instance for the sub FAB added

  - ### calcPreferredSize

    protected Dimension calcPreferredSize()
    Description copied from class: `Button`

    Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

    ###### Returns

    the calculated preferred size based on component content

    Overrides:
      `calcPreferredSize` in class `Button`

  - ### bindFabToContainer

    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.

    ###### Parameters

    - `cnt`: the Container to add the FAB to

    ###### Returns

    a new Container that contains the cnt and the FAB on top or null in the case of a content pane

  - ### bindFabToContainer

    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.

    ###### Parameters

    - `cnt`: the Container to add the FAB to

    - `orientation`: one of Component.RIGHT/LEFT/CENTER

    - `valign`: one of Component.TOP/BOTTOM/CENTER

    ###### Returns

    a new Container that contains the cnt and the FAB on top or null in the case of a content pane

  - ### unbind

    public void unbind()
    Removes the floating action button from its parent

  - ### setText

    public void setText(String text)
    Description copied from class: `Button`

    Overriden to implement the caps mode `#setCapsText(boolean)`

    Sets the Label text

    ###### Parameters

    - `text`: the string that the label presents.
    Specified by:
      `setText` in interface `TextHolder`
    Overrides:
      `setText` in class `Button`

  - ### fireActionEvent

    protected void fireActionEvent(int x, int y)
    Description copied from class: `Button`

    Allows subclasses to override action event behavior for pointer coordinates.

    ###### Parameters

    - `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)

    Overrides:
      `fireActionEvent` in class `Button`

  - ### released

    public void released(int x, int y)
    Description copied from class: `Button`

    Invoked to change the state of the button to the released state

    ###### Parameters

    - `x`: the x position if a touch event triggered this, -1 if this isn't relevant

    - `y`: the y position if a touch event triggered this, -1 if this isn't relevant

    Overrides:
      `released` in class `Button`

  - ### createPopupContent

    protected Container createPopupContent(List<FloatingActionButton> fabs)

    Creates the popup content container to display on the dialog.

    ###### Parameters

    - `fabs`: List of sub FloatingActionButton

    ###### Returns

    a Container that contains all fabs

  - ### showPopupDialog

    protected void showPopupDialog(Dialog dialog)

    Shows the popup Dialog with the sub FABs.

    ###### Parameters

    - `dialog`: the Dialog with all sub FAB's Components

  - ### getFloatingActionTextUIID

    public String getFloatingActionTextUIID()

    ###### Returns

    the floatingActionTextUIID

  - ### setFloatingActionTextUIID

    public void setFloatingActionTextUIID(String floatingActionTextUIID)

    ###### Parameters

    - `floatingActionTextUIID`: the floatingActionTextUIID to set