- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.control.Control
-
- javafx.scene.control.ComboBoxBase<Color>
-
- javafx.scene.control.ColorPicker
-
- Все реализованные интерфейсы:
-
Styleable,EventTarget,Skinnable
public class ColorPicker extends ComboBoxBase<Color>
Контрол ColorPicker позволяет пользователю выбрать цвет из стандартной палитры цветов одним щелчком мыши ИЛИ определить свой собственный цвет.
Свойство
valueсодержит выбранный в данный моментColor. Начальный цвет можно задать, вызвав метод setColor или в конструкторе. Если ничего не указано, используется цвет по умолчанию.Контрол ColorPicker предоставляет палитру цветов с предварительно определённым набором цветов. Если пользователь не хочет выбирать из предварительно определённого набора, он может создать пользовательский цвет, взаимодействуя с диалоговым окном для выбора цвета. Это диалоговое окно предоставляет режимы взаимодействия RGB, HSB и Web для создания новых цветов. Оно также позволяет изменять непрозрачность цвета.
После определения нового цвета пользователи могут выбрать, сохранить его или просто использовать. Если новый цвет сохранён, он появится в области пользовательских цветов на палитре цветов. Также
getCustomColorsвозвращает список сохранённых пользовательских цветов.Свойство
promptTextне поддерживается и, следовательно, является бесполезным. Но оно может быть поддержано в будущем.final ColorPicker colorPicker = new ColorPicker(); colorPicker.setOnAction(new EventHandler() { public void handle(Event t) { Color c = colorPicker.getValue(); System.out.println("New Color's RGB = "+c.getRed()+" "+c.getGreen()+" "+c.getBlue()); } });Внешний вид контрола ColorPicker может быть стилизован тремя способами: режим простой кнопки, режим выпадающего меню или режим раскрывающегося выпадающего меню. По умолчанию используется режим выпадающего меню. Для внешнего вида типа кнопки используйте класс стиля
STYLE_CLASS_BUTTON, а для внешнего вида и поведения типа раскрывающегося выпадающего меню используйте класс стиляSTYLE_CLASS_SPLIT_BUTTON.
илиcolorPicker.getStyleClass().add("button");colorPicker.getStyleClass().add("split-button");- С тех пор:
- JavaFX 2.2
-
Краткое описание свойств
-
Свойства, унаследованные от класса javafx.scene.control.ComboBoxBase
armed, editable, onAction, onHidden, onHiding, onShowing, onShown, promptText, showing, value
-
Свойства, унаследованные от класса javafx.scene.control.Control
contextMenu, skin, tooltip
-
Свойства, унаследованные от класса javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
-
Свойства, унаследованные от класса javafx.scene.Parent
needsLayout
-
Свойства, унаследованные от класса javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, 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
-
-
Краткое описание полей
Поля Модификатор и тип Поле Описание static StringSTYLE_CLASS_BUTTONКласс стиля для указания внешнего вида контрола ColorPicker как кнопки.static StringSTYLE_CLASS_SPLIT_BUTTONКласс стиля для указания внешнего вида контрола ColorPicker как раскрывающегося выпадающего меню.-
Поля, унаследованные от класса javafx.scene.control.ComboBoxBase
ON_HIDDEN, ON_HIDING, ON_SHOWING, ON_SHOWN
-
Поля, унаследованные от класса javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
-
Поля, унаследованные от класса javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Краткое описание конструкторов
Конструкторы Конструктор Описание ColorPicker()Создаёт экземпляр ColorPicker по умолчанию с выбранным цветом белым.ColorPicker(Color color)Создаёт экземпляр ColorPicker и устанавливает выбранный цвет в заданный цвет.
-
Краткое описание методов
Все методыМетодыКонкретные методы Модификатор и тип Метод Описание protected Skin<?>createDefaultSkin()Создаёт новый экземпляр стандартной темы для данного контрола.ObservableList<Color>getCustomColors()Возвращает список пользовательских цветов, добавленных в палитру цветов пользователем.-
Методы, унаследованные от класса javafx.scene.control.ComboBoxBase
arm, armedProperty, disarm, editableProperty, executeAccessibleAction, getOnAction, getOnHidden, getOnHiding, getOnShowing, getOnShown, getPromptText, getValue, hide, isArmed, isEditable, isShowing, onActionProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, promptTextProperty, queryAccessibleAttribute, setEditable, setOnAction, setOnHidden, setOnHiding, setOnShowing, setOnShown, setPromptText, setValue, show, showingProperty, valueProperty
-
Методы, унаследованные от класса javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty
-
Методы, унаследованные от класса javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, 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, widthProperty
-
Методы, унаследованные от класса javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Методы, унаследованные от класса 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, 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, 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, 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, visibleProperty
-
Методы, унаследованные от класса java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Методы, унаследованные от интерфейса javafx.css.Styleable
getStyleableNode
-
-
Подробное описание полей
-
STYLE_CLASS_BUTTON
public static final String STYLE_CLASS_BUTTON
Класс стиля, определяющий вид элемента управления ColorPicker, подобный кнопке.- См. также:
- Постоянные значения полей
-
STYLE_CLASS_SPLIT_BUTTON
public static final String STYLE_CLASS_SPLIT_BUTTON
Класс стиля, определяющий вид элемента управления ColorPicker, подобный элементам управления SplitMenuButton.- См. также:
- Постоянные значения полей
-
-
Подробное описание конструкторов
-
ColorPicker
public ColorPicker()
Создаёт экземпляр ColorPicker по умолчанию с выбранным цветом по умолчанию - белым.
-
ColorPicker
public ColorPicker(Color color)
Создаёт экземпляр ColorPicker и устанавливает выбранный цвет на заданный цвет.- Параметры:
-
color- цвет, который должен быть установлен как текущий выбранный цвет ColorPicker.
-
-
Подробное описание методов
-
getCustomColors
public final ObservableList<Color> getCustomColors()
Получает список пользовательских цветов, добавленных в палитру цветов.- Возвращает:
- список пользовательских цветов
-
createDefaultSkin
protected Skin<?> createDefaultSkin()
Создаёт новый экземпляр по умолчанию для данного элемента управления. Этот метод вызывается для создания внешнего вида для элемента управления, если внешний вид не задан через CSS-fx-skinили не задан явно в подклассе сsetSkin(...).- Переопределяет:
-
createDefaultSkinв классеControl - Возвращает:
- новый экземпляр внешнего вида по умолчанию для данного элемента управления. Если возвращается null, то у элемента управления не будет внешнего вида, если он не задан через css.
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.