- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.control.Control
-
- javafx.scene.control.ButtonBar
-
- すべての実装されたインタフェース:
Styleable
,EventTarget
,Skinnable
public class ButtonBar extends Control
ButtonBarは、HBox
にオペレーティング・システム固有のボタン配置のための機能を追加したものです。 つまり、いずれのNodeも、setButtonData(Node, ButtonData)
メソッドを介して注釈を付け、(getButtons()
リストを介して) ButtonBar内部に配置し、その注釈に基づいてボタン・リスト内の他のすべてのノードおよびButtonBarに指定された包括的なbutton order
を基準として配置することができます。均一ボタン・サイジング
デフォルトでは、ButtonBar内のすべてのボタンは均一のサイズに設定され、つまりすべてのボタンに最も幅の広いボタンの幅が適用されます。
setButtonUniformSize(Node, boolean)
メソッドをブール値falseで呼び出して、ボタンごとにこれを取り消すことが可能です。均一サイジングから除外されたボタンは、優先サイズが取り消されて再設定されることも、測定プロセスに含まれることもないため、そのボタンのサイズがButtonBar内のすべてのボタンに対して計算される最大サイズに影響を与えることはありません。
スクリーンショット
ButtonBarにはWindows、Mac OSおよびLinuxの組込みサポートが付属しているため、3つのスクリーンショットを次に示します。3つのオペレーティング・システムそれぞれに同じボタンが配置されています。
Windows:
Mac OS: Linux:コード・サンプル
ButtonBarをインスタンス化および使用するのは簡単で、次のように記述するだけです。
// Create the ButtonBar instance ButtonBar buttonBar = new ButtonBar(); // Create the buttons to go into the ButtonBar Button yesButton = new Button("Yes"); ButtonBar.setButtonData(yesButton, ButtonData.YES); Button noButton = new Button("No"); ButtonBar.setButtonData(noButton, ButtonData.NO); // Add buttons to the ButtonBar buttonBar.getButtons().addAll(yesButton, noButton);
前述のコード・サンプルでは、ユーザーのオペレーティング・システムを基準にしてYesボタンとNoボタンが配置されます。 つまり、WindowsおよびLinuxではYesボタンがNoボタンの前に配置され、Mac OSではNoの次にYesが配置されます。
ほとんどの場合、OSに固有のレイアウトが最適なレイアウトですが、
button order property
を変更してカスタム・レイアウトにすることもできます。 これらは、ボタン順序の短縮表記である暗号的な文字列です。 Windows、Mac OSおよびLinuxでの組込み順序は次のとおりです。ButtonBarレイアウト表 Windows: L_E+U+FBXI_YNOCAH_R Mac OS: L_HE+U+FBIX_NCYOA_R Linux: L_HE+UNYACBXIO_R これらの各文字の意味の説明は、
ButtonBar.ButtonData
列挙を参照してください。 ただし、ButtonBarにButtonBar.ButtonData.YES
ボタンとButtonBar.ButtonData.NO
ボタンのみを含め、yesボタンを常にnoボタンの前に配置し、かつボタンを右揃え
にすた場合は、次のようにします。// Create the ButtonBar instance ButtonBar buttonBar = new ButtonBar(); // Set the custom button order buttonBar.setButtonOrder("+YN");
- 導入されたバージョン:
- JavaFX 8u40
- 関連項目:
ButtonBar.ButtonData
-
-
プロパティのサマリー
プロパティ Type プロパティ 説明 DoubleProperty
buttonMinWidth
このボタン・バーに配置するすべてのボタンの最小幅を指定します。StringProperty
buttonOrder
標準のボタン・バー内の一般的なボタンの順序。-
クラス javafx.scene.control.Controlから継承されたプロパティ
contextMenu、skin、tooltip
-
クラス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
-
クラス javafx.scene.Parentから継承されたプロパティ
needsLayout
-
クラス javafx.scene.layout.Regionから継承されたプロパティ
background、border、cacheShape、centerShape、height、insets、maxHeight、maxWidth、minHeight、minWidth、opaqueInsets、padding、prefHeight、prefWidth、scaleShape、shape、snapToPixel、width
-
-
ネストされたクラスのサマリー
ネストされたクラス 修飾子と型 クラス 説明 static class
ButtonBar.ButtonData
すべての使用可能なボタン・データ注釈の列挙。
-
フィールドのサマリー
フィールド 修飾子と型 フィールド 説明 static String
BUTTON_ORDER_LINUX
Linux (特にGNOME)でのデフォルトのボタン並び順。static String
BUTTON_ORDER_MAC_OS
Mac OSでのデフォルトのボタン並び順。static String
BUTTON_ORDER_NONE
ボタン並び順がないことを指定するボタン並び順文字列。static String
BUTTON_ORDER_WINDOWS
Windowsでのデフォルトのボタン並び順。-
クラスjavafx.scene.Nodeから継承されたフィールド
BASELINE_OFFSET_SAME_AS_HEIGHT
-
クラス javafx.scene.layout.Regionから継承されたフィールド
USE_COMPUTED_SIZE、USE_PREF_SIZE
-
-
コンストラクタのサマリー
コンストラクタ コンストラクタ 説明 ButtonBar()
ユーザーのオペレーティング・システムのデフォルト・プロパティを使用して、デフォルトのButtonBarインスタンスを作成します。ButtonBar(String buttonOrder)
指定されたボタン順序でButtonBarを作成します(詳細は「buttonOrderProperty()」
を参照)。
-
メソッドのサマリー
すべてのメソッド 静的メソッド インスタンス・メソッド 具象メソッド 修飾子と型 メソッド 説明 DoubleProperty
buttonMinWidthProperty()
このボタン・バーに配置するすべてのボタンの最小幅を指定します。StringProperty
buttonOrderProperty()
標準のボタン・バー内の一般的なボタンの順序。protected Skin<?>
createDefaultSkin()
このコントロールのデフォルト・スキンの新しいインスタンスを作成します。static ButtonBar.ButtonData
getButtonData(Node button)
指定されたボタンに以前に設定されたButtonDataプロパティを返します。double
getButtonMinWidth()
このボタン・バーに配置するすべてのボタンの最小幅を返します。String
getButtonOrder()
現在のbutton order
を返します。ObservableList<Node>
getButtons()
このObservableList内にボタンを配置すると、指定したButtonBar.ButtonData
に基づいてボタンそれぞれを相対的に配置するようButtonBarに指示します。protected Boolean
getInitialFocusTraversable()
このコントロールの初期フォーカス・トラバーサブル状態を返します。これは、JavaFX CSSエンジンが初期値を正しく設定するために使用します。static boolean
isButtonUniformSize(Node button)
指定されたノードが均一サイジング計算に含まれるかどうかを返します。static void
setButtonData(Node button, ButtonBar.ButtonData buttonData)
指定されたボタンに、指定されたButtonDataを設定します。void
setButtonMinWidth(double value)
このボタン・バーに配置するすべてのボタンの最小幅を設定します。void
setButtonOrder(String buttonOrder)
button order
を設定しますstatic void
setButtonUniformSize(Node button, boolean uniformSize)
デフォルトでは、ButtonBar内のすべてのボタンは均一のサイズに設定され、つまりすべてのボタンに最も幅の広いボタンの幅が適用されます。-
クラス javafx.scene.control.Controlから継承されたメソッド
computeMaxHeight、computeMaxWidth、computeMinHeight、computeMinWidth、computePrefHeight、computePrefWidth、contextMenuProperty、executeAccessibleAction、getBaselineOffset、getClassCssMetaData、getContextMenu、getControlCssMetaData、getCssMetaData、getSkin、getTooltip、isResizable、layoutChildren、queryAccessibleAttribute、setContextMenu、setSkin、setTooltip、skinProperty、tooltipProperty
-
クラス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.scene.Parentから継承されたメソッド
getChildren、getChildrenUnmodifiable、getManagedChildren、getStylesheets、isNeedsLayout、layout、lookup、needsLayoutProperty、requestLayout、requestParentLayout、setNeedsLayout、updateBounds
-
クラス 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.css.Styleableから継承されたメソッド
getStyleableNode
-
-
-
-
プロパティの詳細
-
buttonOrder
public final StringProperty buttonOrderProperty
標準のボタン・バー内の一般的なボタンの順序。ButtonBar.ButtonData
列挙値ごとに1文字です。 オペレーティング・システムのデフォルトのボタン順序(BUTTON_ORDER_WINDOWS
、BUTTON_ORDER_MAC_OS
およびBUTTON_ORDER_LINUX
)も使用可能です。
-
buttonMinWidth
public final DoubleProperty buttonMinWidthProperty
このボタン・バーに配置するすべてのボタンの最小幅を指定します。
-
-
フィールドの詳細
-
BUTTON_ORDER_WINDOWS
public static final String BUTTON_ORDER_WINDOWS
Windowsでのデフォルトのボタン並び順。- 関連項目:
- 定数フィールド値
-
BUTTON_ORDER_MAC_OS
public static final String BUTTON_ORDER_MAC_OS
Mac OSでのデフォルトのボタン並び順。- 関連項目:
- 定数フィールド値
-
BUTTON_ORDER_LINUX
public static final String BUTTON_ORDER_LINUX
Linux (特にGNOME)でのデフォルトのボタン並び順。- 関連項目:
- 定数フィールド値
-
BUTTON_ORDER_NONE
public static final String BUTTON_ORDER_NONE
ボタン並び順がないことを指定するボタン並び順文字列。 つまり、ボタンはgetButtons()
リスト内の順序で配置されます。 レイアウトでHBoxを使用する場合と異なる点は、ボタンが右揃えであることのみです。- 関連項目:
- 定数フィールド値
-
-
コンストラクタの詳細
-
ButtonBar
public ButtonBar()
ユーザーのオペレーティング・システムのデフォルト・プロパティを使用して、デフォルトのButtonBarインスタンスを作成します。
-
ButtonBar
public ButtonBar(String buttonOrder)
指定されたボタン順序でButtonBarを作成します(詳細は「buttonOrderProperty()」
を参照)。- パラメータ:
buttonOrder
- このボタン・バー・インスタンスで使用するボタン順序。
-
-
メソッドの詳細
-
setButtonData
public static void setButtonData(Node button, ButtonBar.ButtonData buttonData)
指定されたボタンに、指定されたButtonDataを設定します。 その後でこのボタンがButtonBar
に配置されるとき、バーの他のすべてのボタンを基準にして正しい位置に配置されます。- パラメータ:
button
- 指定されたButtonBar.ButtonData
値で注釈付けするボタン。buttonData
- ボタンの指定に使用するButtonData。
-
getButtonData
public static ButtonBar.ButtonData getButtonData(Node button)
指定されたボタンに以前に設定されたButtonDataプロパティを返します。 これが設定されていない場合、このメソッドはnullを返します。- パラメータ:
button
- 以前に設定されたButtonDataを返すボタン。- 戻り値:
- 指定されたボタンの以前に設定されたButtonDataプロパティ
-
setButtonUniformSize
public static void setButtonUniformSize(Node button, boolean uniformSize)
デフォルトでは、ButtonBar内のすべてのボタンは均一のサイズに設定され、つまりすべてのボタンに最も幅の広いボタンの幅が適用されます。 setButtonUniformSizeメソッドをブール値falseで呼び出して、ボタンごとにこれを取り消すことが可能です。均一サイジングから除外されたボタンは、優先サイズが取り消されて再設定されることも、測定プロセスに含まれることもないため、そのボタンのサイズがButtonBar内のすべてのボタンに対して計算される最大サイズに影響を与えることはありません。
- パラメータ:
button
- 均一サイジングに含める、または均一サイジングから除外するボタン。uniformSize
- ボタンに均一サイジングを適用する場合はブールのtrue、ボタンを均一サイジングから除外する場合はfalse。
-
isButtonUniformSize
public static boolean isButtonUniformSize(Node button)
指定されたノードが均一サイジング計算に含まれるかどうかを返します。 デフォルトでは、(setButtonUniformSize(Node, boolean)
を介して)除外されていないノードはすべてここでtrueを返します。- パラメータ:
button
- ボタン- 戻り値:
- ボタンが均一なサイズの計算の一部である場合はtrue
-
createDefaultSkin
protected Skin<?> createDefaultSkin()
このコントロールのデフォルト・スキンの新しいインスタンスを作成します。 これは、CSS-fx-skin
を介してスキンが提供されていない場合にコントロール用のスキンを作成するために、またはsetSkin(...)
を使用してサブクラスで明示的に設定するために呼び出されます。- オーバーライド:
createDefaultSkin
、クラス:Control
- 戻り値:
- このコントロールのデフォルト・スキンの新しいインスタンス。 nullの場合、コントロールにはスキンがありません(Cssで提供されている場合を除く)。
-
getButtons
public final ObservableList<Node> getButtons()
このObservableList内にボタンを配置すると、指定したButtonBar.ButtonData
に基づいてボタンそれぞれを相対的に配置するようButtonBarに指示します。 ボタンのButtonDataを設定するには、setButtonData(Node, ButtonData)
を呼び出して、関連するButtonDataを渡すだけです。- 戻り値:
- 現在ボタン・バー内にあるすべてのボタンが含まれた、ボタンの追加や削除が可能なリスト。
-
buttonOrderProperty
public final StringProperty buttonOrderProperty()
標準のボタン・バー内の一般的なボタンの順序。ButtonBar.ButtonData
列挙値ごとに1文字です。 オペレーティング・システムのデフォルトのボタン順序(BUTTON_ORDER_WINDOWS
、BUTTON_ORDER_MAC_OS
およびBUTTON_ORDER_LINUX
)も使用可能です。
-
setButtonOrder
public final void setButtonOrder(String buttonOrder)
button order
を設定します- パラメータ:
buttonOrder
- 現在設定されているボタン順序(デフォルトではOSに固有のボタン順序になります)。
-
getButtonOrder
public final String getButtonOrder()
現在のbutton order
を返します。- 戻り値:
- 現在の
ボタン順序
。
-
buttonMinWidthProperty
public final DoubleProperty buttonMinWidthProperty()
このボタン・バーに配置するすべてのボタンの最小幅を指定します。
-
setButtonMinWidth
public final void setButtonMinWidth(double value)
このボタン・バーに配置するすべてのボタンの最小幅を設定します。- パラメータ:
value
- 最小幅の値
-
getButtonMinWidth
public final double getButtonMinWidth()
このボタン・バーに配置するすべてのボタンの最小幅を返します。- 戻り値:
- 最小幅の値
-
getInitialFocusTraversable
protected Boolean getInitialFocusTraversable()
このコントロールの初期フォーカス・トラバーサブル状態を返します。これは、JavaFX CSSエンジンが初期値を正しく設定するために使用します。 このメソッドはオーバーライドされます。既定のUIコントロールでは、フォーカス・トラバーサルがtrueに設定されていますが、このコントロールには適切ではありません。- オーバーライド:
- クラス
Control
のgetInitialFocusTraversable
- 戻り値:
- このコントロールの最初のフォーカス・トラバーサル状態
- 導入されたバージョン:
- 9
-
-