public class HBox extends Pane
HBoxの例:
HBox hbox = new HBox(8); // spacing = 8
hbox.getChildren().addAll(new Label("Name:), new TextBox());
HBoxは、子(サイズ変更可能な場合)を優先幅にサイズ変更し、fillHeightプロパティを使用して、HBox自体の高さ全体に表示するように子の高さをサイズ変更するか、子の高さを優先値に維持するかを決定します(fillHeightのデフォルト値はtrueです)。 コンテンツの位置合せは、alignmentプロパティ(デフォルト値はPos.TOP_LEFT)によって制御されます。
hboxが優先幅よりも大きくなるようにサイズ変更された場合、子の幅はデフォルトではそれぞれの優先値に維持され、追加スペースは使用されません。 1つ以上の子に追加スペースを割り当てる必要があるアプリケーションでは、オプションで子に対してhgrow制約を設定できます。 詳細は、「オプションのレイアウト制約」を参照してください。
HBoxでは、管理対象の各子をそれぞれの可視プロパティの値に関係なくレイアウトします。管理対象外の子は無視されます。
| width | height | |
|---|---|---|
| 最小 | 左/右の枠+各子の最小幅の合計+各子間のスペース | 上/下の枠+子の最小高の中の最大値 |
| 優先 | 左/右の枠+各子の優先幅の合計+各子間のスペース | 上/下の枠+子の優先高の中の最大値 |
| 最大 | Double.MAX_VALUE | Double.MAX_VALUE |
hboxの最大幅および最大高には制限がないため、親に割り当てられているスペースすべてを満たすために、親がその優先サイズより大きいサイズに変更される可能性があります。
HBoxには、サイズ範囲を直接設定するためのプロパティが用意されています。 これらのプロパティはデフォルトでセンチネル値USE_COMPUTED_SIZEに設定されますが、アプリケーションでは必要に応じてこれらを別の値に設定できます。
hbox.setPrefWidth(400);
アプリケーションでは、これらのプロパティの設定をUSE_COMPUTED_SIZEに戻すことで、計算された値を復元できます。
HBoxはデフォルトではそのコンテンツをクリップしないため、子の最小サイズが原因でhbox内に子を収めることができない場合は、子の境界がhbox自体の境界の外側まで拡大することがあります。
| 制約 | Type | 説明 |
|---|---|---|
| hgrow | javafx.scene.layout.Priority | 子の水平方向の拡大優先度。 |
| マージン | javafx.geometry.Insets | 子の外側のマージン領域。 |
たとえば、hboxでTextFieldに追加スペースをすべて割り当てる必要がある場合は、次のようにします。
HBox hbox = new HBox();
TextField field = new TextField();
HBox.setHgrow(field, Priority.ALWAYS);
hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));
複数の子に同じ拡大優先度が設定されている場合は、各子にスペースが均等に割り当てられます。 HBoxはその最大幅を上限として子を拡大するため、子にDouble.MAX_VALUE以外の最大幅が設定されているときには、アプリケーションでその値をオーバーライドして子を拡大できるようにする必要がある場合があります。 たとえば:
HBox hbox = new HBox();
Button button1 = new Button("Add");
Button button2 = new Button("Remove");
HBox.setHgrow(button1, Priority.ALWAYS);
HBox.setHgrow(button2, Priority.ALWAYS);
button1.setMaxWidth(Double.MAX_VALUE);
button2.setMaxWidth(Double.MAX_VALUE);
hbox.getChildren().addAll(button1, button2);
| Type | プロパティと説明 |
|---|---|
ObjectProperty<Pos> |
alignment
hboxの幅と高さの範囲内での子の全体的な位置合せ。
|
BooleanProperty |
fillHeight
サイズ変更可能な子のサイズを変更してhboxの高さ全体に表示するか、それとも、好みの高さを維持して、
alignment vpos値に従って位置合せするか。 |
DoubleProperty |
spacing
hboxの子の間の水平方向の総スペース。
|
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthneedsLayoutaccessibleHelp, 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, visibleUSE_COMPUTED_SIZE, USE_PREF_SIZEBASELINE_OFFSET_SAME_AS_HEIGHT| コンストラクタと説明 |
|---|
HBox()
スペースを0としてHBoxレイアウトを作成します。
|
HBox(double spacing)
子間のスペースを指定してHBoxレイアウトを作成します。
|
HBox(double spacing, Node... children)
子間のスペースを指定してHBoxレイアウトを作成します。
|
HBox(Node... children)
スペースを0としてHBoxレイアウトを作成します。
|
| 修飾子と型 | メソッドと説明 |
|---|---|
ObjectProperty<Pos> |
alignmentProperty()
hboxの幅と高さの範囲内での子の全体的な位置合せ。
|
static void |
clearConstraints(Node child)
子ノードからすべてのhbox制約を削除します。
|
protected double |
computeMinHeight(double width)
このリージョンの最小高を計算します。
|
protected double |
computeMinWidth(double height)
このリージョンの最小幅を計算します。
|
protected double |
computePrefHeight(double width)
指定された幅に対するこのリージョンの優先高を計算します。Regionのサブクラスでは、このメソッドをオーバーライドして、そのコンテンツおよびレイアウト手法に基づいて適切な値を返す必要があります。
|
protected double |
computePrefWidth(double height)
指定された高さに対するこのリージョンの優先幅を計算します。
|
BooleanProperty |
fillHeightProperty()
サイズ変更可能な子のサイズを変更してhboxの高さ全体に表示するか、それとも、好みの高さを維持して、
alignment vpos値に従って位置合せするか。 |
Pos |
getAlignment()
プロパティalignmentの値を取得します。
|
double |
getBaselineOffset()
最初に管理される子に基づいて、ベースライン・オフセットを計算します。
|
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
Orientation |
getContentBias()
レイアウト用にノードのサイズ変更バイアスの向きを返します。
|
List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
NodeのCssMetaDataがリフレクションなしでアクセス可能になるように、このメソッドは
Node.getClassCssMetaData()に委任する必要があります。 |
static Priority |
getHgrow(Node child)
子のhgrow制約を返します(設定されている場合)。
|
static Insets |
getMargin(Node child)
子のマージン制約を返します(設定されている場合)。
|
double |
getSpacing()
プロパティspacingの値を取得します。
|
boolean |
isFillHeight()
プロパティfillHeightの値を取得します。
|
protected void |
layoutChildren()
この
Parentの子をレイアウトするレイアウト・パス中に起動されます。 |
void |
requestLayout()
次のシーンがレンダリングされる前に実行するレイアウト・パスを要求します。
|
void |
setAlignment(Pos value)
プロパティalignmentの値を設定します。
|
void |
setFillHeight(boolean value)
プロパティfillHeightの値を設定します。
|
static void |
setHgrow(Node child, Priority value)
hboxに含まれている場合に、子の水平方向の拡大優先度を設定します。
|
static void |
setMargin(Node child, Insets value)
hboxに含まれている場合に、子のマージンを設定します。
|
void |
setSpacing(double value)
プロパティspacingの値を設定します。
|
DoubleProperty |
spacingProperty()
hboxの子の間の水平方向の総スペース。
|
getChildrenbackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, 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, snapSize, snapSpace, snapToPixelProperty, widthPropertygetChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBoundsaccessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, 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, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visiblePropertypublic final DoubleProperty spacingProperty
public final ObjectProperty<Pos> alignmentProperty
public final BooleanProperty fillHeightProperty
alignment vpos値に従って位置合せするか。 hboxの垂直位置合せがBASELINEに設定されている場合、このプロパティは無視され、子はそれぞれの優先高に合せてサイズ変更されることに注意してください。 public HBox()
public HBox(double spacing)
spacing - 各子間の水平方向のスペースの量。public HBox(Node... children)
children - このペインの子の初期設定。public HBox(double spacing,
Node... children)
spacing - 各子間の水平方向のスペースの量。children - このペインの子の初期設定。public static void setHgrow(Node child, Priority value)
child - hboxの子value - 子の水平方向の拡大優先度public static Priority getHgrow(Node child)
child - hboxの子ノードpublic static void setMargin(Node child, Insets value)
child - hboxの子ノードvalue - 子の周囲の空白のマージンpublic static Insets getMargin(Node child)
child - hboxの子ノードpublic static void clearConstraints(Node child)
child - 子ノードpublic final DoubleProperty spacingProperty()
public final void setSpacing(double value)
public final double getSpacing()
public final ObjectProperty<Pos> alignmentProperty()
public final void setAlignment(Pos value)
public final Pos getAlignment()
public final BooleanProperty fillHeightProperty()
alignment vpos値に従って位置合せするか。 hboxの垂直位置合せがBASELINEに設定されている場合、このプロパティは無視され、子はそれぞれの優先高に合せてサイズ変更されることに注意してください。 public final void setFillHeight(boolean value)
alignment vpos値に従って位置合せするか。 hboxの垂直位置合せがBASELINEに設定されている場合、このプロパティは無視され、子はそれぞれの優先高に合せてサイズ変更されることに注意してください。 public final boolean isFillHeight()
alignment vpos値に従って位置合せするか。 hboxの垂直位置合せがBASELINEに設定されている場合、このプロパティは無視され、子はそれぞれの優先高に合せてサイズ変更されることに注意してください。 public Orientation getContentBias()
NodeResizableのサブクラスはこのメソッドをオーバーライドし、適切な値を返す必要があります。
getContentBias、クラスNodeNode.isResizable()、Node.minWidth(double)、Node.minHeight(double)、Node.prefWidth(double)、Node.prefHeight(double)、Node.maxWidth(double)、Node.maxHeight(double)protected double computeMinWidth(double height)
RegioncomputeMinWidth、クラスRegionheight - 最小幅が高さに依存する場合に使用する必要がある高さprotected double computeMinHeight(double width)
RegioncomputeMinHeight、クラスRegionwidth - 最小高が幅に依存する場合に使用する必要がある幅protected double computePrefWidth(double height)
RegioncomputePrefWidth、クラスRegionheight - 推奨される幅がそれに依存する場合に使用する必要がある高さprotected double computePrefHeight(double width)
RegioncomputePrefHeight、クラスRegionwidth - 推奨される高さがそれに依存する場合に使用する必要がある幅public void requestLayout()
Parentこの親がレイアウト・ルートまたは管理対象外のいずれかである場合は、シーンのダーティ・レイアウト・リストに直接追加されます。そうでない場合は、requestParentLayoutが起動されます。
requestLayout、クラスParentpublic double getBaselineOffset()
ParentNode.getBaselineOffset()を返します。 getBaselineOffset、クラスParentprotected void layoutChildren()
ParentParentの子をレイアウトするレイアウト・パス中に起動されます。 デフォルトでは、管理対象のサイズ変更可能なコンテンツのサイズをその優先サイズに合せて設定するのみで、ノードの配置は行われません。
サブクラスは必要に応じてこの関数をオーバーライドし、コンテンツをレイアウトする必要があります。
layoutChildren、クラスParentpublic static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()に委任する必要があります。getCssMetaData、インタフェースStyleablegetCssMetaData、クラスRegionCopyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.