- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.Group
-
- All Implemented Interfaces:
Styleable
,EventTarget
@DefaultProperty("children") public class Group extends Parent
AGroup
node contains an ObservableList of children that are rendered in order whenever this node is rendered.A
Group
will take on the collective bounds of its children and is not directly resizable.Any transform, effect, or state applied to a
Group
will be applied to all children of that group. Such transforms and effects will NOT be included in this Group's layout bounds, however if transforms and effects are set directly on children of this Group, those will be included in this Group's layout bounds.By default, a
Group
will "auto-size" its managed resizable children to their preferred sizes during the layout pass to ensure that Regions and Controls are sized properly as their state changes. If an application needs to disable this auto-sizing behavior, then it should setautoSizeChildren
tofalse
and understand that if the preferred size of the children change, they will not automatically resize (so buyer beware!).Group Example:
import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.shape.*; import java.lang.Math; Group g = new Group(); for (int i = 0; i < 5; i++) { Rectangle r = new Rectangle(); r.setY(i * 20); r.setWidth(100); r.setHeight(10); r.setFill(Color.RED); g.getChildren().add(r); }
- Since:
- JavaFX 2.0
-
-
Property Summary
Properties Type Property Description BooleanProperty
autoSizeChildren
Controls whether or not thisGroup
will automatically resize any managed resizable children to their preferred sizes during the layout pass.-
Properties declared in class 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
-
Properties declared in class javafx.scene.Parent
needsLayout
-
-
Field Summary
-
Fields declared in class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanProperty
autoSizeChildrenProperty()
Controls whether or not thisGroup
will automatically resize any managed resizable children to their preferred sizes during the layout pass.ObservableList<Node>
getChildren()
Gets the list of children of thisGroup
.boolean
isAutoSizeChildren()
Gets the value of the property autoSizeChildren.protected void
layoutChildren()
Group implements layoutChildren such that each child is resized to its preferred size, if the child is resizable.double
prefHeight(double width)
Group defines the preferred height as simply being the height of its layout bounds, which in turn is simply the union of the layout bounds of all of its children.double
prefWidth(double height)
Group defines the preferred width as simply being the width of its layout bounds, which in turn is simply the union of the layout bounds of all of its children.void
setAutoSizeChildren(boolean value)
Sets the value of the property autoSizeChildren.-
Methods declared in 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, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, 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, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, 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, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, 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, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, 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
-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods declared in class javafx.scene.Parent
computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods declared in interface javafx.css.Styleable
getStyleableNode, getStyleClass
-
-
-
-
Property Detail
-
autoSizeChildren
public final BooleanProperty autoSizeChildrenProperty
Controls whether or not thisGroup
will automatically resize any managed resizable children to their preferred sizes during the layout pass. If set tofalse
, then the application is responsible for setting the size of this Group's resizable children, otherwise such nodes may end up with a zero width/height and will not be visible. This variable has no effect on content nodes which are not resizable (Shape, Text, etc).- Default value:
- true
- See Also:
isAutoSizeChildren()
,setAutoSizeChildren(boolean)
-
-
Constructor Detail
-
Group
public Group()
Constructs a group.
-
Group
public Group(Node... children)
Constructs a group consisting of children.- Parameters:
children
- children.
-
Group
public Group(Collection<Node> children)
Constructs a group consisting of the given children.- Parameters:
children
- children of the group- Throws:
NullPointerException
- if the specified collection is null- Since:
- JavaFX 8.0
-
-
Method Detail
-
setAutoSizeChildren
public final void setAutoSizeChildren(boolean value)
Sets the value of the property autoSizeChildren.- Property description:
- Controls whether or not this
Group
will automatically resize any managed resizable children to their preferred sizes during the layout pass. If set tofalse
, then the application is responsible for setting the size of this Group's resizable children, otherwise such nodes may end up with a zero width/height and will not be visible. This variable has no effect on content nodes which are not resizable (Shape, Text, etc). - Default value:
- true
-
isAutoSizeChildren
public final boolean isAutoSizeChildren()
Gets the value of the property autoSizeChildren.- Property description:
- Controls whether or not this
Group
will automatically resize any managed resizable children to their preferred sizes during the layout pass. If set tofalse
, then the application is responsible for setting the size of this Group's resizable children, otherwise such nodes may end up with a zero width/height and will not be visible. This variable has no effect on content nodes which are not resizable (Shape, Text, etc). - Default value:
- true
-
autoSizeChildrenProperty
public final BooleanProperty autoSizeChildrenProperty()
Controls whether or not thisGroup
will automatically resize any managed resizable children to their preferred sizes during the layout pass. If set tofalse
, then the application is responsible for setting the size of this Group's resizable children, otherwise such nodes may end up with a zero width/height and will not be visible. This variable has no effect on content nodes which are not resizable (Shape, Text, etc).- Default value:
- true
- See Also:
isAutoSizeChildren()
,setAutoSizeChildren(boolean)
-
getChildren
public ObservableList<Node> getChildren()
Gets the list of children of thisGroup
.- Overrides:
getChildren
in classParent
- Returns:
- the list of children of this
Group
.
-
prefWidth
public double prefWidth(double height)
Group defines the preferred width as simply being the width of its layout bounds, which in turn is simply the union of the layout bounds of all of its children. That is, the preferred width is the one that it is at, because a Group cannot be resized. Note: as the layout bounds in autosize Group depend on the Group to be already laid-out, this call will do the layout of the Group if necessary.- Overrides:
prefWidth
in classNode
- Parameters:
height
- This parameter is ignored by Group- Returns:
- The layout bounds width
- See Also:
Node.isResizable()
,Node.getContentBias()
,Node.autosize()
-
prefHeight
public double prefHeight(double width)
Group defines the preferred height as simply being the height of its layout bounds, which in turn is simply the union of the layout bounds of all of its children. That is, the preferred height is the one that it is at, because a Group cannot be resized. Note: as the layout bounds in autosize Group depend on the Group to be already laid-out, this call will do the layout of the Group if necessary.- Overrides:
prefHeight
in classNode
- Parameters:
width
- This parameter is ignored by Group- Returns:
- The layout bounds height
- See Also:
Node.getContentBias()
,Node.autosize()
-
layoutChildren
protected void layoutChildren()
Group implements layoutChildren such that each child is resized to its preferred size, if the child is resizable. Non-resizable children are simply left alone. IfautoSizeChildren
is false, then Group does nothing in this method.- Overrides:
layoutChildren
in classParent
-
-