Spec-Zone .ru
спецификации, руководства, описания, API
|
public class ToggleButton extends ButtonBase implements Toggle
ToggleButton
is a specialized control which has the ability to be
selected. Typically a ToggleButton
is rendered similarly to a Button.
However, they are two different types of Controls. A Button is a "command"
button which invokes a function when clicked. A ToggleButton
on the
other hand is simply a control with a Boolean indicating whether it has been
selected.
ToggleButton
can also be placed in groups. By default, a
ToggleButton
is not in a group. When in groups, only one
ToggleButton
at a time within that group can be selected. To put two
ToggleButtons
in the same group, simply assign them both the same
value for ToggleGroup
.
Unlike RadioButtons
, ToggleButtons
in a
ToggleGroup
do not attempt to force at least one selected
ToggleButton
in the group. That is, if a ToggleButton
is
selected, clicking on it will cause it to become unselected. With
RadioButton
, clicking on the selected button in the group will have
no effect.
Example:
ToggleButton tb1 = new ToggleButton("toggle button 1");
ToggleButton tb2 = new ToggleButton("toggle button 2");
ToggleButton tb3 = new ToggleButton("toggle button 3");
ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
MnemonicParsing is enabled by default for ToggleButton.
Type | Property and Description |
---|---|
BooleanProperty |
selected
Indicates whether this toggle button is selected.
|
ObjectProperty<ToggleGroup> |
toggleGroup
The
ToggleGroup to which this ToggleButton belongs. |
armed, onAction
alignment, contentDisplay, ellipsisString, font, graphic, graphicTextGap, labelPadding, mnemonicParsing, textAlignment, textFill, textOverrun, text, underline, wrapText
contextMenu, height, maxHeight, maxWidth, minHeight, minWidth, prefHeight, prefWidth, skinClassName, skin, tooltip, width
needsLayout
blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, 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, visible
USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
ToggleButton()
Creates a toggle button with an empty string for its label.
|
ToggleButton(java.lang.String text)
Creates a toggle button with the specified text as its label.
|
ToggleButton(java.lang.String text,
Node graphic)
Creates a toggle button with the specified text and icon for its label.
|
Modifier and Type | Method and Description |
---|---|
void |
fire()
Invoked when a user gesture indicates that an event for this
ButtonBase should occur. |
ToggleGroup |
getToggleGroup()
Gets the value of the property toggleGroup.
|
boolean |
isSelected()
Gets the value of the property selected.
|
BooleanProperty |
selectedProperty()
Indicates whether this toggle button is selected.
|
void |
setSelected(boolean value)
Sets the value of the property selected.
|
void |
setToggleGroup(ToggleGroup value)
Sets the value of the property toggleGroup.
|
ObjectProperty<ToggleGroup> |
toggleGroupProperty()
The
ToggleGroup to which this ToggleButton belongs. |
arm, armedProperty, disarm, getOnAction, isArmed, onActionProperty, setOnAction
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, getAlignment, getContentBias, getContentDisplay, getEllipsisString, getFont, getGraphic, getGraphicTextGap, getLabelPadding, getText, getTextAlignment, getTextFill, getTextOverrun, graphicProperty, graphicTextGapProperty, isMnemonicParsing, isUnderline, isWrapText, labelPaddingProperty, mnemonicParsingProperty, setAlignment, setContentDisplay, setEllipsisString, setFont, setGraphic, setGraphicTextGap, setMnemonicParsing, setText, setTextAlignment, setTextFill, setTextOverrun, setUnderline, setWrapText, textAlignmentProperty, textFillProperty, textOverrunProperty, textProperty, underlineProperty, wrapTextProperty
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getSkin, getTooltip, getUserAgentStylesheet, getWidth, heightProperty, intersects, isResizable, layoutChildren, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, setContextMenu, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setSkinClassName, setTooltip, setWidth, skinClassNameProperty, skinProperty, tooltipProperty, widthProperty
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, setNeedsLayout
addEventFilter, addEventHandler, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, 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, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToSceneTransformProperty, lookupAll, managedProperty, mouseTransparentProperty, 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, pickOnBoundsProperty, pressedProperty, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, visibleProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getProperties, getUserData, setUserData
public final BooleanProperty selectedProperty
selectedProperty
in interface Toggle
isSelected()
,
setSelected(boolean)
public final ObjectProperty<ToggleGroup> toggleGroupProperty
ToggleGroup
to which this ToggleButton
belongs. A
ToggleButton
can only be in one group at any one time. If the
group is changed, then the button is removed from the old group prior to
being added to the new group.toggleGroupProperty
in interface Toggle
getToggleGroup()
,
setToggleGroup(ToggleGroup)
public ToggleButton()
public ToggleButton(java.lang.String text)
text
- A text string for its label.public ToggleButton(java.lang.String text, Node graphic)
text
- A text string for its label.graphic
- the icon for its label.public final void setSelected(boolean value)
setSelected
in interface Toggle
value
- true
to make this Toggle
selected.public final boolean isSelected()
isSelected
in interface Toggle
true
if this Toggle
is selected.public final BooleanProperty selectedProperty()
selectedProperty
in interface Toggle
isSelected()
,
setSelected(boolean)
public final void setToggleGroup(ToggleGroup value)
setToggleGroup
in interface Toggle
value
- The new ToggleGroup
.ToggleGroup
to which this ToggleButton
belongs. A
ToggleButton
can only be in one group at any one time. If the
group is changed, then the button is removed from the old group prior to
being added to the new group.public final ToggleGroup getToggleGroup()
getToggleGroup
in interface Toggle
ToggleGroup
to which this Toggle
belongs.ToggleGroup
to which this ToggleButton
belongs. A
ToggleButton
can only be in one group at any one time. If the
group is changed, then the button is removed from the old group prior to
being added to the new group.public final ObjectProperty<ToggleGroup> toggleGroupProperty()
ToggleGroup
to which this ToggleButton
belongs. A
ToggleButton
can only be in one group at any one time. If the
group is changed, then the button is removed from the old group prior to
being added to the new group.toggleGroupProperty
in interface Toggle
getToggleGroup()
,
setToggleGroup(ToggleGroup)
public void fire()
ButtonBase
should occur.
If invoked, this method will be executed regardless of the status of
ButtonBase.arm()
.
fire
in class ButtonBase
Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to