public class Region
  Comment     Returned-by     Constructor-argument     Method-argument     Field-type     Type-bound     Links  

Region is the base class for all JavaFX Node-based UI Controls, and all layout containers. It is a resizable Parent node which can be styled from CSS. It can have multiple backgrounds and borders. It is designed to support as much of the CSS3 specification for backgrounds and borders as is relevant to JavaFX. The full specification is available at the W3C.

Every Region has its layout bounds, which are specified to be (0, 0, width, height). A Region might draw outside these bounds. The content area of a Region is the area which is occupied for the layout of its children. This area is, by default, the same as the layout bounds of the Region, but can be modified by either the properties of a border (either with BorderStrokes or BorderImages), and by padding. The padding can be negative, such that the content area of a Region might extend beyond the layout bounds of the Region, but does not affect the layout bounds.

A Region has a Background, and a Border, although either or both of these might be empty. The Background of a Region is made up of zero or more BackgroundFills, and zero or more BackgroundImages. Likewise, the border of a Region is defined by its Border, which is made up of zero or more BorderStrokes and zero or more BorderImages. All BackgroundFills are drawn first, followed by BackgroundImages, BorderStrokes, and finally BorderImages. The content is drawn above all backgrounds and borders. If a BorderImage is present (and loaded all images properly), then no BorderStrokes are actually drawn, although they are considered for computing the position of the content area (see the stroke width property of a BorderStroke). These semantics are in line with the CSS 3 specification. The purpose of these semantics are to allow an application to specify a fallback BorderStroke to be displayed in the case that an ImageStroke fails to download or load.

By default a Region appears as a Rectangle. A BackgroundFill radii might cause the Rectangle to appear rounded. This affects not only making the visuals look like a rounded rectangle, but it also causes the picking behavior of the Region to act like a rounded rectangle, such that locations outside the corner radii are ignored. A Region can be made to use any shape, however, by specifing the shape property. If a shape is specified, then all BackgroundFills, BackgroundImages, and BorderStrokes will be applied to the shape. BorderImages are not used for Regions which have a shape specified.

A Region with a shape

Although the layout bounds of a Region are not influenced by any Border or Background, the content area insets and the picking area of the Region are. The insets of the Region define the distance between the edge of the layout bounds and the edge of the content area. For example, if the Region layout bounds are (x=0, y=0, width=200, height=100), and the insets are (top=10, right=20, bottom=30, left=40), then the content area bounds will be (x=40, y=10, width=140, height=60). A Region subclass which is laying out its children should compute and honor these content area bounds.

By default a Region inherits the layout behavior of its superclass, Parent, which means that it will resize any resizable child nodes to their preferred size, but will not reposition them. If an application needs more specific layout behavior, then it should use one of the Region subclasses: StackPane, HBox, VBox, TilePane, FlowPane, BorderPane, GridPane, or AnchorPane.

To implement a more custom layout, a Region subclass must override computePrefWidth, computePrefHeight, and layoutChildren. Note that layoutChildren is called automatically by the scene graph while executing a top-down layout pass and it should not be invoked directly by the region subclass.

Region subclasses which layout their children will position nodes by setting layoutX/layoutY and do not alter translateX/translateY, which are reserved for adjustments and animation.

extends Parent

Since:  JavaFX 2.0