Class SelectionBox<T>
- All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable
- Direct Known Subclasses:
DayOfWeekPicker, TimeRangePicker
A versatile and customizable selection control that combines the features of ComboBox
and ChoiceBox with enhanced selection capabilities.
Unlike ComboBox and ChoiceBox, which are limited to single selection modes, SelectionBox
supports both single and multiple selection modes, providing greater flexibility for various UI requirements.
Additionally, SelectionBox offers the ability to add extra buttons, enabling users to perform
common selection actions swiftly, such as selecting all items, clearing selections, or applying predefined selection criteria.
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.BooleanPropertyControls whether animation is enabled for the popup opening/closing transitions.final javafx.beans.property.BooleanPropertyControls whether the popup should auto-hide when an item or the extra button is clicked.final javafx.beans.property.ObjectProperty<javafx.scene.Node> final javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.SelectionMode> Provides a read-only property that directly exposes the currentSelectionModeof this control without requiring multilevel checks on the underlyingMultipleSelectionModel.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Returns the graphic property of this ChoicePicker.final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>> Retrieves the property object for the string converter that formats the display of individual items.final javafx.beans.property.ListProperty<T> The list of items to be displayed in the SelectionBox.final javafx.beans.property.ObjectProperty<javafx.scene.Node> final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked after the SelectionPopup has been hidden.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked before the SelectionPopup is hidden.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked before the SelectionPopup is shown.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked after the SelectionPopup has been shown.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Returns the property holding the placeholder node, which is displayed when there are no items.final javafx.beans.property.StringPropertyReturns the prompt text property of this SelectionBox.final javafx.beans.property.BooleanPropertyReturns the BooleanProperty that controls the read-only state of the SelectionBox.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Retrieves the property object for a string converter used to format the display of selected items.final javafx.beans.property.ObjectProperty<javafx.scene.control.MultipleSelectionModel<T>> Returns the property object for the selection model used by this SelectionBox.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Properties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltipProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible -
Field Summary
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new SelectionBox instance.SelectionBox(Collection<T> items) Constructs a new selection box with the specified collection of items.SelectionBox(T... items) Constructs a new selection box and populates it with the provided items. -
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.BooleanPropertyControls whether animation is enabled for the popup opening/closing transitions.final javafx.beans.property.BooleanPropertyControls whether the popup should auto-hide when an item or the extra button is clicked.final javafx.beans.property.ObjectProperty<javafx.scene.Node> protected javafx.scene.control.Skin<?> javafx.scene.control.ButtoncreateExtraButton(String text, Runnable action) Creates an extra button with the specified text and action.javafx.scene.control.ButtoncreateExtraButton(String text, javafx.scene.Node graphic, Runnable action) Creates an extra button with the specified text, graphic, and action.final javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.SelectionMode> Provides a read-only property that directly exposes the currentSelectionModeof this control without requiring multilevel checks on the underlyingMultipleSelectionModel.final javafx.scene.NodeGets the value of thebottomproperty.static List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> final javafx.scene.control.SelectionModeGets the value of thecurrentSelectionModeproperty.final javafx.scene.NodeGets the value of thegraphicproperty.final javafx.util.StringConverter<T> Gets the value of theitemConverterproperty.final javafx.collections.ObservableList<T> getItems()Gets the value of theitemsproperty.final javafx.scene.NodegetLeft()Gets the value of theleftproperty.final javafx.event.EventHandler<javafx.stage.WindowEvent> Gets the value of theonHiddenproperty.final javafx.event.EventHandler<javafx.stage.WindowEvent> Gets the value of theonHidingproperty.final javafx.event.EventHandler<javafx.stage.WindowEvent> Gets the value of theonShowingproperty.final javafx.event.EventHandler<javafx.stage.WindowEvent> Gets the value of theonShownproperty.final javafx.scene.NodeGets the value of theplaceholderproperty.final StringGets the value of thepromptTextproperty.final javafx.scene.NodegetRight()Gets the value of therightproperty.Gets the value of theselectedItemsConverterproperty.final javafx.scene.control.MultipleSelectionModel<T> Gets the value of theselectionModelproperty.final javafx.scene.NodegetTop()Gets the value of thetopproperty.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Returns the graphic property of this ChoicePicker.final voidhide()Hides the popup by setting the "showPopup" property to false on the component's properties.final booleanGets the value of theanimationEnabledproperty.final booleanGets the value of theautoHideOnSelectionproperty.final booleanGets the value of thereadOnlyproperty.final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>> Retrieves the property object for the string converter that formats the display of individual items.final javafx.beans.property.ListProperty<T> The list of items to be displayed in the SelectionBox.final javafx.beans.property.ObjectProperty<javafx.scene.Node> final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked after the SelectionPopup has been hidden.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked before the SelectionPopup is hidden.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked before the SelectionPopup is shown.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> The event handler property invoked after the SelectionPopup has been shown.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Returns the property holding the placeholder node, which is displayed when there are no items.final javafx.beans.property.StringPropertyReturns the prompt text property of this SelectionBox.final javafx.beans.property.BooleanPropertyReturns the BooleanProperty that controls the read-only state of the SelectionBox.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Retrieves the property object for a string converter used to format the display of selected items.final javafx.beans.property.ObjectProperty<javafx.scene.control.MultipleSelectionModel<T>> Returns the property object for the selection model used by this SelectionBox.final voidsetAnimationEnabled(boolean value) Sets the value of theanimationEnabledproperty.final voidsetAutoHideOnSelection(boolean autoHideOnSelection) Sets the value of theautoHideOnSelectionproperty.final voidsetBottom(javafx.scene.Node bottom) Sets the value of thebottomproperty.final voidsetGraphic(javafx.scene.Node graphic) Sets the value of thegraphicproperty.final voidsetItemConverter(javafx.util.StringConverter<T> itemConverter) Sets the value of theitemConverterproperty.final voidSets the value of theitemsproperty.final voidsetLeft(javafx.scene.Node left) Sets the value of theleftproperty.final voidsetOnHidden(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonHiddenproperty.final voidsetOnHiding(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonHidingproperty.final voidsetOnShowing(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonShowingproperty.final voidsetOnShown(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonShownproperty.final voidsetPlaceholder(javafx.scene.Node placeholder) Sets the value of theplaceholderproperty.final voidsetPromptText(String promptText) Sets the value of thepromptTextproperty.final voidsetReadOnly(boolean readOnly) Sets the value of thereadOnlyproperty.final voidsetRight(javafx.scene.Node right) Sets the value of therightproperty.final voidsetSelectedItemsConverter(javafx.util.StringConverter<List<T>> selectedItemsConverter) Sets the value of theselectedItemsConverterproperty.final voidsetSelectionModel(javafx.scene.control.MultipleSelectionModel<T> selectionModel) Sets the value of theselectionModelproperty.final voidsetTop(javafx.scene.Node top) Sets the value of thetopproperty.final voidshow()Displays the popup by setting the "showPopup" property to true on the component's properties.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Methods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipPropertyMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthPropertyMethods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsMethods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, requestFocusTraversal, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visiblePropertyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
items
The list of items to be displayed in the SelectionBox.- See Also:
-
top
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> topProperty- See Also:
-
bottom
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> bottomProperty- See Also:
-
left
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> leftProperty- See Also:
-
right
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> rightProperty- See Also:
-
placeholder
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> placeholderPropertyReturns the property holding the placeholder node, which is displayed when there are no items.- See Also:
-
graphic
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicPropertyReturns the graphic property of this ChoicePicker. The graphic is an optional graphical representation that can be displayed alongside other text or elements within the picker.- See Also:
-
promptText
public final javafx.beans.property.StringProperty promptTextPropertyReturns the prompt text property of this SelectionBox. The prompt text is an optional text that can be displayed in the picker when no item is selected.- See Also:
-
autoHideOnSelection
public final javafx.beans.property.BooleanProperty autoHideOnSelectionPropertyControls whether the popup should auto-hide when an item or the extra button is clicked.When set to false, the popup remains visible regardless of interaction, allowing continued interaction in both single and multiple selection modes. This is useful when the user needs to make multiple selections or interact with the extra button without closing the popup.
When set to true, the behavior differs based on the selection mode:
- In multiple selection mode, clicking the extra button will hide the popup to finalize the selection, but clicking an item will not hide the popup, allowing further selections.
- In single selection mode, clicking any item or the extra button does not automatically hide the popup unless explicitly handled.
- See Also:
-
selectedItemsConverter
public final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<List<T>>> selectedItemsConverterPropertyRetrieves the property object for a string converter used to format the display of selected items. This converter allows for customization of how selected items are represented in the UI. For instance, if the selected item collection is[1, 2, 3, 4, 5], the converter can format this list to display as "1, 2, 3, 4, 5". By setting a custom converter, it is possible to modify the display to any desired format, such as "1~5".If the selected items list is
nullor empty, thepromptTextProperty()value will be used instead, so there is no need to handle these cases within the converter. You can also choose to always return your own string (for example, "Select" or "Please choose")selectionBox.setSelectedItemsConverter( new SimpleStringConverter<>(selectedItems -> { // return "Select"; return selectionBox.getPromptText(); }) );The
selectedItemsConverterPropertyprovides a way to bind the display logic to UI components, enabling dynamic updates whenever the selected items change or the converter is redefined.- See Also:
-
itemConverter
public final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>> itemConverterPropertyRetrieves the property object for the string converter that formats the display of individual items. This property allows for customization of how each item is represented as a string in the UI.- See Also:
-
readOnly
public final javafx.beans.property.BooleanProperty readOnlyPropertyReturns the BooleanProperty that controls the read-only state of the SelectionBox. When set to true, the SelectionBox will be in read-only mode, preventing user interaction.Can be set via CSS using the
-fx-read-onlyproperty. Valid values are:trueorfalse. The default value isfalse.- See Also:
-
selectionModel
public final javafx.beans.property.ObjectProperty<javafx.scene.control.MultipleSelectionModel<T>> selectionModelPropertyReturns the property object for the selection model used by this SelectionBox. The selection model defines the APIs responsible for handling selection, primarily in the context of multiple or single selection modes.- See Also:
-
currentSelectionMode
public final javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.SelectionMode> currentSelectionModePropertyProvides a read-only property that directly exposes the currentSelectionModeof this control without requiring multilevel checks on the underlyingMultipleSelectionModel. This is particularly convenient for child classes or external consumers who need to quickly determine whether the mode isSelectionMode.SINGLE,SelectionMode.MULTIPLE, ornull(in case there is no active selection model).To modify the selection mode, call
getSelectionModel().setSelectionMode(...)directly, since this property itself is read-only.- See Also:
-
animationEnabled
public final javafx.beans.property.BooleanProperty animationEnabledPropertyControls whether animation is enabled for the popup opening/closing transitions.Can be set via CSS using the
-fx-animation-enabledproperty. Valid values are:trueorfalse. The default value isfalse.- See Also:
-
onShowing
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onShowingPropertyThe event handler property invoked before the SelectionPopup is shown.This maps to
WindowEvent.WINDOW_SHOWING. Use this to prepare data or UI state right before the popup becomes visible.- See Also:
-
onShown
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onShownPropertyThe event handler property invoked after the SelectionPopup has been shown.This maps to
WindowEvent.WINDOW_SHOWN. Use this to run logic that depends on the popup being visible (e.g., focusing a field inside the popup).- See Also:
-
onHiding
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onHidingPropertyThe event handler property invoked before the SelectionPopup is hidden.This maps to
WindowEvent.WINDOW_HIDING. Use this to validate or persist a transient state before closing the popup.- See Also:
-
onHidden
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onHiddenPropertyThe event handler property invoked after the SelectionPopup has been hidden.This maps to
WindowEvent.WINDOW_HIDDEN. Use this to perform cleanup work after the popup is fully closed.- See Also:
-
-
Constructor Details
-
SelectionBox
public SelectionBox()Constructs a new SelectionBox instance. This custom control extends functionality to allow for enhanced selection capabilities with predefined style classes and quick selection buttons. The constructor performs the following operations: - Sets style classes for the control, including "combo-box-base," "combo-box," and the default style class. - Adds customizable quick selection buttons to the top of the popup area. - Binds the current selection mode to an internal selection mode property. - Initializes a custom multiple selection model, binding it to the items property. - Configures the component's size to use its preferred size as both minimum and maximum size. -
SelectionBox
Constructs a new selection box with the specified collection of items.- Parameters:
items- the collection of items to populate the SelectionBox
-
SelectionBox
Constructs a new selection box and populates it with the provided items.- Parameters:
items- The initial items to populate the selection box. These items will be added to the selection box's list of choices.
-
-
Method Details
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheetin classjavafx.scene.layout.Region
-
hide
public final void hide()Hides the popup by setting the "showPopup" property to false on the component's properties. -
show
public final void show()Displays the popup by setting the "showPopup" property to true on the component's properties. -
createDefaultSkin
protected javafx.scene.control.Skin<?> createDefaultSkin()- Overrides:
createDefaultSkinin classjavafx.scene.control.Control
-
itemsProperty
The list of items to be displayed in the SelectionBox.- Returns:
- the list property containing the items
- See Also:
-
setItems
Sets the value of theitemsproperty.- Property description:
- The list of items to be displayed in the SelectionBox.
- Parameters:
items- the value for theitemsproperty- See Also:
-
getItems
Gets the value of theitemsproperty.- Property description:
- The list of items to be displayed in the SelectionBox.
- Returns:
- the value of the
itemsproperty - See Also:
-
topProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> topProperty()- Returns:
- the
topproperty - See Also:
-
getTop
public final javafx.scene.Node getTop()Gets the value of thetopproperty.- Property description:
- Returns:
- the value of the
topproperty - See Also:
-
setTop
public final void setTop(javafx.scene.Node top) Sets the value of thetopproperty.- Property description:
- Parameters:
top- the value for thetopproperty- See Also:
-
bottomProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> bottomProperty()- Returns:
- the
bottomproperty - See Also:
-
getBottom
public final javafx.scene.Node getBottom()Gets the value of thebottomproperty.- Property description:
- Returns:
- the value of the
bottomproperty - See Also:
-
setBottom
public final void setBottom(javafx.scene.Node bottom) Sets the value of thebottomproperty.- Property description:
- Parameters:
bottom- the value for thebottomproperty- See Also:
-
leftProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> leftProperty()- Returns:
- the
leftproperty - See Also:
-
getLeft
public final javafx.scene.Node getLeft()Gets the value of theleftproperty.- Property description:
- Returns:
- the value of the
leftproperty - See Also:
-
setLeft
public final void setLeft(javafx.scene.Node left) Sets the value of theleftproperty.- Property description:
- Parameters:
left- the value for theleftproperty- See Also:
-
rightProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> rightProperty()- Returns:
- the
rightproperty - See Also:
-
getRight
public final javafx.scene.Node getRight()Gets the value of therightproperty.- Property description:
- Returns:
- the value of the
rightproperty - See Also:
-
setRight
public final void setRight(javafx.scene.Node right) Sets the value of therightproperty.- Property description:
- Parameters:
right- the value for therightproperty- See Also:
-
placeholderProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> placeholderProperty()Returns the property holding the placeholder node, which is displayed when there are no items.- Returns:
- the placeholder property
- See Also:
-
getPlaceholder
public final javafx.scene.Node getPlaceholder()Gets the value of theplaceholderproperty.- Property description:
- Returns the property holding the placeholder node, which is displayed when there are no items.
- Returns:
- the value of the
placeholderproperty - See Also:
-
setPlaceholder
public final void setPlaceholder(javafx.scene.Node placeholder) Sets the value of theplaceholderproperty.- Property description:
- Returns the property holding the placeholder node, which is displayed when there are no items.
- Parameters:
placeholder- the value for theplaceholderproperty- See Also:
-
createExtraButton
Creates an extra button with the specified text and action. The button will be styled with the "extra-button" class and will adjust its visibility based on its managed property. The button's maximum width will be set to the maximum double value.- Parameters:
text- the text to be displayed on the buttonaction- the action to be executed when the button is clicked- Returns:
- the created Button instance
-
createExtraButton
public javafx.scene.control.Button createExtraButton(String text, javafx.scene.Node graphic, Runnable action) Creates an extra button with the specified text, graphic, and action. The created button will be styled with "extra-button" class and will adjust its visibility based on its managed property. The button's maximum width will be set to the maximum double value.- Parameters:
text- the text to be displayed on the buttongraphic- the graphic node to be displayed on the buttonaction- the action to be executed when the button is clicked- Returns:
- the created Button instance
-
graphicProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicProperty()Returns the graphic property of this ChoicePicker. The graphic is an optional graphical representation that can be displayed alongside other text or elements within the picker.- Returns:
- the ObjectProperty containing the graphical Node.
- See Also:
-
setGraphic
public final void setGraphic(javafx.scene.Node graphic) Sets the value of thegraphicproperty.- Property description:
- Returns the graphic property of this ChoicePicker. The graphic is an optional graphical representation that can be displayed alongside other text or elements within the picker.
- Parameters:
graphic- the value for thegraphicproperty- See Also:
-
getGraphic
public final javafx.scene.Node getGraphic()Gets the value of thegraphicproperty.- Property description:
- Returns the graphic property of this ChoicePicker. The graphic is an optional graphical representation that can be displayed alongside other text or elements within the picker.
- Returns:
- the value of the
graphicproperty - See Also:
-
promptTextProperty
public final javafx.beans.property.StringProperty promptTextProperty()Returns the prompt text property of this SelectionBox. The prompt text is an optional text that can be displayed in the picker when no item is selected.- Returns:
- the StringProperty containing the prompt text.
- See Also:
-
setPromptText
Sets the value of thepromptTextproperty.- Property description:
- Returns the prompt text property of this SelectionBox. The prompt text is an optional text that can be displayed in the picker when no item is selected.
- Parameters:
promptText- the value for thepromptTextproperty- See Also:
-
getPromptText
Gets the value of thepromptTextproperty.- Property description:
- Returns the prompt text property of this SelectionBox. The prompt text is an optional text that can be displayed in the picker when no item is selected.
- Returns:
- the value of the
promptTextproperty - See Also:
-
autoHideOnSelectionProperty
public final javafx.beans.property.BooleanProperty autoHideOnSelectionProperty()Controls whether the popup should auto-hide when an item or the extra button is clicked.When set to false, the popup remains visible regardless of interaction, allowing continued interaction in both single and multiple selection modes. This is useful when the user needs to make multiple selections or interact with the extra button without closing the popup.
When set to true, the behavior differs based on the selection mode:
- In multiple selection mode, clicking the extra button will hide the popup to finalize the selection, but clicking an item will not hide the popup, allowing further selections.
- In single selection mode, clicking any item or the extra button does not automatically hide the popup unless explicitly handled.
- Returns:
- a BooleanProperty to control the auto-hide behavior of the popup.
- See Also:
-
isAutoHideOnSelection
public final boolean isAutoHideOnSelection()Gets the value of theautoHideOnSelectionproperty.- Property description:
- Controls whether the popup should auto-hide when an item or the extra button is clicked.
When set to false, the popup remains visible regardless of interaction, allowing continued interaction in both single and multiple selection modes. This is useful when the user needs to make multiple selections or interact with the extra button without closing the popup.
When set to true, the behavior differs based on the selection mode:
- In multiple selection mode, clicking the extra button will hide the popup to finalize the selection, but clicking an item will not hide the popup, allowing further selections.
- In single selection mode, clicking any item or the extra button does not automatically hide the popup unless explicitly handled.
- Returns:
- the value of the
autoHideOnSelectionproperty - See Also:
-
setAutoHideOnSelection
public final void setAutoHideOnSelection(boolean autoHideOnSelection) Sets the value of theautoHideOnSelectionproperty.- Property description:
- Controls whether the popup should auto-hide when an item or the extra button is clicked.
When set to false, the popup remains visible regardless of interaction, allowing continued interaction in both single and multiple selection modes. This is useful when the user needs to make multiple selections or interact with the extra button without closing the popup.
When set to true, the behavior differs based on the selection mode:
- In multiple selection mode, clicking the extra button will hide the popup to finalize the selection, but clicking an item will not hide the popup, allowing further selections.
- In single selection mode, clicking any item or the extra button does not automatically hide the popup unless explicitly handled.
- Parameters:
autoHideOnSelection- the value for theautoHideOnSelectionproperty- See Also:
-
selectedItemsConverterProperty
public final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<List<T>>> selectedItemsConverterProperty()Retrieves the property object for a string converter used to format the display of selected items. This converter allows for customization of how selected items are represented in the UI. For instance, if the selected item collection is[1, 2, 3, 4, 5], the converter can format this list to display as "1, 2, 3, 4, 5". By setting a custom converter, it is possible to modify the display to any desired format, such as "1~5".If the selected items list is
nullor empty, thepromptTextProperty()value will be used instead, so there is no need to handle these cases within the converter. You can also choose to always return your own string (for example, "Select" or "Please choose")selectionBox.setSelectedItemsConverter( new SimpleStringConverter<>(selectedItems -> { // return "Select"; return selectionBox.getPromptText(); }) );The
selectedItemsConverterPropertyprovides a way to bind the display logic to UI components, enabling dynamic updates whenever the selected items change or the converter is redefined.- Returns:
- the property object for the string converter that formats the display of selected items.
- See Also:
-
getSelectedItemsConverter
Gets the value of theselectedItemsConverterproperty.- Property description:
- Retrieves the property object for a string converter used to format the display of selected items.
This converter allows for customization of how selected items are represented in the UI.
For instance, if the selected item collection is
[1, 2, 3, 4, 5], the converter can format this list to display as "1, 2, 3, 4, 5". By setting a custom converter, it is possible to modify the display to any desired format, such as "1~5".If the selected items list is
nullor empty, thepromptTextProperty()value will be used instead, so there is no need to handle these cases within the converter. You can also choose to always return your own string (for example, "Select" or "Please choose")selectionBox.setSelectedItemsConverter( new SimpleStringConverter<>(selectedItems -> { // return "Select"; return selectionBox.getPromptText(); }) );The
selectedItemsConverterPropertyprovides a way to bind the display logic to UI components, enabling dynamic updates whenever the selected items change or the converter is redefined. - Returns:
- the value of the
selectedItemsConverterproperty - See Also:
-
setSelectedItemsConverter
public final void setSelectedItemsConverter(javafx.util.StringConverter<List<T>> selectedItemsConverter) Sets the value of theselectedItemsConverterproperty.- Property description:
- Retrieves the property object for a string converter used to format the display of selected items.
This converter allows for customization of how selected items are represented in the UI.
For instance, if the selected item collection is
[1, 2, 3, 4, 5], the converter can format this list to display as "1, 2, 3, 4, 5". By setting a custom converter, it is possible to modify the display to any desired format, such as "1~5".If the selected items list is
nullor empty, thepromptTextProperty()value will be used instead, so there is no need to handle these cases within the converter. You can also choose to always return your own string (for example, "Select" or "Please choose")selectionBox.setSelectedItemsConverter( new SimpleStringConverter<>(selectedItems -> { // return "Select"; return selectionBox.getPromptText(); }) );The
selectedItemsConverterPropertyprovides a way to bind the display logic to UI components, enabling dynamic updates whenever the selected items change or the converter is redefined. - Parameters:
selectedItemsConverter- the value for theselectedItemsConverterproperty- See Also:
-
itemConverterProperty
public final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>> itemConverterProperty()Retrieves the property object for the string converter that formats the display of individual items. This property allows for customization of how each item is represented as a string in the UI.- Returns:
- the property object for the string converter used to format individual items.
- See Also:
-
getItemConverter
Gets the value of theitemConverterproperty.- Property description:
- Retrieves the property object for the string converter that formats the display of individual items. This property allows for customization of how each item is represented as a string in the UI.
- Returns:
- the value of the
itemConverterproperty - See Also:
-
setItemConverter
Sets the value of theitemConverterproperty.- Property description:
- Retrieves the property object for the string converter that formats the display of individual items. This property allows for customization of how each item is represented as a string in the UI.
- Parameters:
itemConverter- the value for theitemConverterproperty- See Also:
-
readOnlyProperty
public final javafx.beans.property.BooleanProperty readOnlyProperty()Returns the BooleanProperty that controls the read-only state of the SelectionBox. When set to true, the SelectionBox will be in read-only mode, preventing user interaction.Can be set via CSS using the
-fx-read-onlyproperty. Valid values are:trueorfalse. The default value isfalse.- Returns:
- the BooleanProperty controlling the read-only state of the SelectionBox.
- See Also:
-
isReadOnly
public final boolean isReadOnly()Gets the value of thereadOnlyproperty.- Property description:
- Returns the BooleanProperty that controls the read-only state of the SelectionBox.
When set to true, the SelectionBox will be in read-only mode, preventing user interaction.
Can be set via CSS using the
-fx-read-onlyproperty. Valid values are:trueorfalse. The default value isfalse. - Returns:
- the value of the
readOnlyproperty - See Also:
-
setReadOnly
public final void setReadOnly(boolean readOnly) Sets the value of thereadOnlyproperty.- Property description:
- Returns the BooleanProperty that controls the read-only state of the SelectionBox.
When set to true, the SelectionBox will be in read-only mode, preventing user interaction.
Can be set via CSS using the
-fx-read-onlyproperty. Valid values are:trueorfalse. The default value isfalse. - Parameters:
readOnly- the value for thereadOnlyproperty- See Also:
-
getSelectionModel
Gets the value of theselectionModelproperty.- Property description:
- Returns the property object for the selection model used by this SelectionBox. The selection model defines the APIs responsible for handling selection, primarily in the context of multiple or single selection modes.
- Returns:
- the value of the
selectionModelproperty - See Also:
-
selectionModelProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.control.MultipleSelectionModel<T>> selectionModelProperty()Returns the property object for the selection model used by this SelectionBox. The selection model defines the APIs responsible for handling selection, primarily in the context of multiple or single selection modes.- Returns:
- the ObjectProperty containing the selection model.
- See Also:
-
setSelectionModel
Sets the value of theselectionModelproperty.- Property description:
- Returns the property object for the selection model used by this SelectionBox. The selection model defines the APIs responsible for handling selection, primarily in the context of multiple or single selection modes.
- Parameters:
selectionModel- the value for theselectionModelproperty- See Also:
-
getCurrentSelectionMode
public final javafx.scene.control.SelectionMode getCurrentSelectionMode()Gets the value of thecurrentSelectionModeproperty.- Property description:
- Provides a read-only property that directly exposes the current
SelectionModeof this control without requiring multilevel checks on the underlyingMultipleSelectionModel. This is particularly convenient for child classes or external consumers who need to quickly determine whether the mode isSelectionMode.SINGLE,SelectionMode.MULTIPLE, ornull(in case there is no active selection model).To modify the selection mode, call
getSelectionModel().setSelectionMode(...)directly, since this property itself is read-only. - Returns:
- the value of the
currentSelectionModeproperty - See Also:
-
currentSelectionModeProperty
public final javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.SelectionMode> currentSelectionModeProperty()Provides a read-only property that directly exposes the currentSelectionModeof this control without requiring multilevel checks on the underlyingMultipleSelectionModel. This is particularly convenient for child classes or external consumers who need to quickly determine whether the mode isSelectionMode.SINGLE,SelectionMode.MULTIPLE, ornull(in case there is no active selection model).To modify the selection mode, call
getSelectionModel().setSelectionMode(...)directly, since this property itself is read-only.- Returns:
- a read-only
SelectionModeproperty - See Also:
-
animationEnabledProperty
public final javafx.beans.property.BooleanProperty animationEnabledProperty()Controls whether animation is enabled for the popup opening/closing transitions.Can be set via CSS using the
-fx-animation-enabledproperty. Valid values are:trueorfalse. The default value isfalse.- Returns:
- the animation enabled property
- See Also:
-
isAnimationEnabled
public final boolean isAnimationEnabled()Gets the value of theanimationEnabledproperty.- Property description:
- Controls whether animation is enabled for the popup opening/closing transitions.
Can be set via CSS using the
-fx-animation-enabledproperty. Valid values are:trueorfalse. The default value isfalse. - Returns:
- the value of the
animationEnabledproperty - See Also:
-
setAnimationEnabled
public final void setAnimationEnabled(boolean value) Sets the value of theanimationEnabledproperty.- Property description:
- Controls whether animation is enabled for the popup opening/closing transitions.
Can be set via CSS using the
-fx-animation-enabledproperty. Valid values are:trueorfalse. The default value isfalse. - Parameters:
value- the value for theanimationEnabledproperty- See Also:
-
onShowingProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onShowingProperty()The event handler property invoked before the SelectionPopup is shown.This maps to
WindowEvent.WINDOW_SHOWING. Use this to prepare data or UI state right before the popup becomes visible.- Returns:
- the property holding the handler invoked before showing the popup
- See Also:
-
setOnShowing
public final void setOnShowing(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonShowingproperty.- Property description:
- The event handler property invoked before the SelectionPopup is shown.
This maps to
WindowEvent.WINDOW_SHOWING. Use this to prepare data or UI state right before the popup becomes visible. - Parameters:
value- the value for theonShowingproperty- See Also:
-
getOnShowing
public final javafx.event.EventHandler<javafx.stage.WindowEvent> getOnShowing()Gets the value of theonShowingproperty.- Property description:
- The event handler property invoked before the SelectionPopup is shown.
This maps to
WindowEvent.WINDOW_SHOWING. Use this to prepare data or UI state right before the popup becomes visible. - Returns:
- the value of the
onShowingproperty - See Also:
-
onShownProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onShownProperty()The event handler property invoked after the SelectionPopup has been shown.This maps to
WindowEvent.WINDOW_SHOWN. Use this to run logic that depends on the popup being visible (e.g., focusing a field inside the popup).- Returns:
- the property holding the handler invoked after the popup is shown
- See Also:
-
setOnShown
public final void setOnShown(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonShownproperty.- Property description:
- The event handler property invoked after the SelectionPopup has been shown.
This maps to
WindowEvent.WINDOW_SHOWN. Use this to run logic that depends on the popup being visible (e.g., focusing a field inside the popup). - Parameters:
value- the value for theonShownproperty- See Also:
-
getOnShown
public final javafx.event.EventHandler<javafx.stage.WindowEvent> getOnShown()Gets the value of theonShownproperty.- Property description:
- The event handler property invoked after the SelectionPopup has been shown.
This maps to
WindowEvent.WINDOW_SHOWN. Use this to run logic that depends on the popup being visible (e.g., focusing a field inside the popup). - Returns:
- the value of the
onShownproperty - See Also:
-
onHidingProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onHidingProperty()The event handler property invoked before the SelectionPopup is hidden.This maps to
WindowEvent.WINDOW_HIDING. Use this to validate or persist a transient state before closing the popup.- Returns:
- the property holding the handler invoked before the popup is hidden
- See Also:
-
setOnHiding
public final void setOnHiding(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonHidingproperty.- Property description:
- The event handler property invoked before the SelectionPopup is hidden.
This maps to
WindowEvent.WINDOW_HIDING. Use this to validate or persist a transient state before closing the popup. - Parameters:
value- the value for theonHidingproperty- See Also:
-
getOnHiding
public final javafx.event.EventHandler<javafx.stage.WindowEvent> getOnHiding()Gets the value of theonHidingproperty.- Property description:
- The event handler property invoked before the SelectionPopup is hidden.
This maps to
WindowEvent.WINDOW_HIDING. Use this to validate or persist a transient state before closing the popup. - Returns:
- the value of the
onHidingproperty - See Also:
-
onHiddenProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.stage.WindowEvent>> onHiddenProperty()The event handler property invoked after the SelectionPopup has been hidden.This maps to
WindowEvent.WINDOW_HIDDEN. Use this to perform cleanup work after the popup is fully closed.- Returns:
- the property holding the handler invoked after the popup is hidden
- See Also:
-
setOnHidden
public final void setOnHidden(javafx.event.EventHandler<javafx.stage.WindowEvent> value) Sets the value of theonHiddenproperty.- Property description:
- The event handler property invoked after the SelectionPopup has been hidden.
This maps to
WindowEvent.WINDOW_HIDDEN. Use this to perform cleanup work after the popup is fully closed. - Parameters:
value- the value for theonHiddenproperty- See Also:
-
getOnHidden
public final javafx.event.EventHandler<javafx.stage.WindowEvent> getOnHidden()Gets the value of theonHiddenproperty.- Property description:
- The event handler property invoked after the SelectionPopup has been hidden.
This maps to
WindowEvent.WINDOW_HIDDEN. Use this to perform cleanup work after the popup is fully closed. - Returns:
- the value of the
onHiddenproperty - See Also:
-
getClassCssMetaData
-
getControlCssMetaData
- Overrides:
getControlCssMetaDatain classjavafx.scene.control.Control
-