APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene

public Class Group

extends Parent
Class Inheritance
Known Direct Subclasses
com.sun.javafx.tk.quantum.OverlayWarning
Annotations
@DefaultProperty:children
Imports
com.sun.javafx.scene.GroupHelper, javafx.beans.DefaultProperty, javafx.beans.property.BooleanProperty, .BooleanPropertyBase, javafx.collections.ObservableList, javafx.geometry.Bounds, java.util.Collection

A Group 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 set autoSizeChildren to false 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

Field Summary

Modifier and TypeField and Description
private BooleanProperty
autoSizeChildren

Controls whether or not this Group will automatically resize any managed resizable children to their preferred sizes during the layout pass.

Inherited from javafx.scene.Parent:
DIRTY_CHILDREN_THRESHOLDlayoutFlaglayoutRoot

Constructor Summary

AccessConstructor and Description
public
Group()

Constructs a group.

public
Group(Node...
children.
children
)

Constructs a group consisting of children.

public
Group(Collection<Node>
children of the group
children
)

Constructs a group consisting of the given children.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
private Bounds
public ObservableList<Node>

Returns:

the list of children of this Group.
getChildren
()

Overrides javafx.scene.Parent.getChildren.

Gets the list of children of this Group.

public final boolean
protected void
layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

Group implements layoutChildren such that each child is resized to its preferred size, if the child is resizable.

public double
minHeight(double width)

Overrides javafx.scene.Parent.minHeight.

Returns the node's minimum height for use in layout calculations.

public double
minWidth(double height)

Overrides javafx.scene.Parent.minWidth.

Returns the node's minimum width for use in layout calculations.

public double

Returns:

The layout bounds height
prefHeight
(double
This parameter is ignored by Group
width
)

Overrides javafx.scene.Parent.prefHeight.

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.

public double

Returns:

The layout bounds width
prefWidth
(double
This parameter is ignored by Group
height
)

Overrides javafx.scene.Parent.prefWidth.

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.

public final void
setAutoSizeChildren(boolean value)

Inherited from javafx.scene.Parent:
childBoundsChangedchildVisibilityChangedclearSizeCachecomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetBaselineOffsetgetChildrenUnmodifiablegetManagedChildrengetStylesheetsisConnectedisCurrentLayoutChildisNeedsLayoutisPerformingLayoutisSceneRootlayoutlookuplookupAllmanagedChildChangedmarkViewOrderChildrenDirtyneedsLayoutPropertynodeResolvedOrientationChangednotifyManagedChangedpickChildrenNodeprintSeqqueryAccessibleAttributereleaseAccessiblerequestLayoutrequestLayoutrequestParentLayoutrequestParentLayoutscenesChangedsetDerivedDepthTestsetLayoutFlagsetNeedsLayouttest_getRemovedtest_getViewOrderChildrentoBacktoFrontupdateBoundsvalidatePG

Field Detail

autoSizeChildrenback to summary
private BooleanProperty autoSizeChildren

Controls whether or not this Group will automatically resize any managed resizable children to their preferred sizes during the layout pass. If set to false, 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

Constructor Detail

Groupback to summary
public Group()

Constructs a group.

Groupback to summary
public Group(Node... children)

Constructs a group consisting of children.

Parameters
children:Node[]

children.

Groupback to summary
public Group(Collection<Node> children)

Constructs a group consisting of the given children.

Parameters
children:Collection<Node>

children of the group

Exceptions
NullPointerException:
if the specified collection is null
Since
JavaFX 8.0

Method Detail

autoSizeChildrenPropertyback to summary
public final BooleanProperty autoSizeChildrenProperty()
doComputeLayoutBoundsback to summary
private Bounds doComputeLayoutBounds()

Hides javafx.scene.Node.doComputeLayoutBounds.

getChildrenback to summary
public ObservableList<Node> getChildren()

Overrides javafx.scene.Parent.getChildren.

Gets the list of children of this Group.

Returns:ObservableList<Node>

the list of children of this Group.

Annotations
@Override
isAutoSizeChildrenback to summary
public final boolean isAutoSizeChildren()
layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.Parent.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. If autoSizeChildren is false, then Group does nothing in this method.

Annotations
@Override
minHeightback to summary
public double minHeight(double width)

Overrides javafx.scene.Parent.minHeight.

Doc from javafx.scene.Node.minHeight.

Returns the node's minimum height for use in layout calculations. If the node is resizable, its parent should not resize its height any smaller than this value. If the node is not resizable, returns its layoutBounds height.

Layout code which calls this method should first check the content-bias of the node. If the node has a horizontal content-bias, then callers should pass in a width value that the minimum height should be based on. If the node has either a vertical or null content-bias, then the caller should pass in -1.

Node subclasses with a horizontal content-bias should honor the width parameter whether -1 or a positive value. All other subclasses may ignore the width parameter (which will likely be -1).

If Node's maxHeight(double) is lower than this number, minHeight takes precedence. This means the Node should never be resized below minHeight.

Annotations
@Override
minWidthback to summary
public double minWidth(double height)

Overrides javafx.scene.Parent.minWidth.

Doc from javafx.scene.Node.minWidth.

Returns the node's minimum width for use in layout calculations. If the node is resizable, its parent should not resize its width any smaller than this value. If the node is not resizable, returns its layoutBounds width.

Layout code which calls this method should first check the content-bias of the node. If the node has a vertical content-bias, then callers should pass in a height value that the minimum width should be based on. If the node has either a horizontal or null content-bias, then the caller should pass in -1.

Node subclasses with a vertical content-bias should honor the height parameter whether -1 or a positive value. All other subclasses may ignore the height parameter (which will likely be -1).

If Node's maxWidth(double) is lower than this number, minWidth takes precedence. This means the Node should never be resized below minWidth.

Annotations
@Override
prefHeightback to summary
public double prefHeight(double width)

Overrides javafx.scene.Parent.prefHeight.

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.

Parameters
width:double

This parameter is ignored by Group

Returns:double

The layout bounds height

Annotations
@Override
prefWidthback to summary
public double prefWidth(double height)

Overrides javafx.scene.Parent.prefWidth.

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.

Parameters
height:double

This parameter is ignored by Group

Returns:double

The layout bounds width

Annotations
@Override
setAutoSizeChildrenback to summary
public final void setAutoSizeChildren(boolean value)