Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx Pane vs Region?

According to the documentation, both Region and Pane will resize any resizable child nodes to their preferred size, but will not reposition them.

So i can't see where the differencies between these two containers remain and when use one or another.

like image 510
QuidNovi Avatar asked Jul 31 '12 17:07

QuidNovi


People also ask

What is region JavaFX?

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.

What is a pane in JavaFX?

Layout panes are containers which are used for flexible and dynamic arrangements of UI controls within a scene graph of a JavaFX application. As a window is resized, the layout pane automatically repositions and resizes the nodes it contains.

What is the difference between HBox and VBox pane?

HBox is a subclass of Pane that lays out its children next to each other, in a horizontal row. VBox is a subclass of Pane that lays out its children in vertical column. An HBox might be used as the bottom component in a BorderPane, making it possible to line up several components along the bottom of the border pane.

Can a scene have multiple panes JavaFX?

The Scene it self can only have one root Pane. So if you want 2 panes in the Scene you need 3. In your code this can look like this: StackPane rootPane = new StackPane(); Scene scene = new Scene(rootPane,...); Pane pane1 = new Pane(); Pane pane2 = new Pane(); rootPane.


1 Answers

Region is a superclass for components that have child nodes.

The difference is that Region doesn't allow to manipulate its children through the public API. The Region.getChildren() method is protected:

new Region().getChildren().add(...); // doesn't compile
new Pane().getChildren().add(...); // works

Why is that?

Because Region is dedicated to component developers, and it allows them to choose if they want to allow API users to work with children directly (like Pane, HBox, etc.) or not (like charts).

like image 193
Sergey Grinev Avatar answered Sep 24 '22 01:09

Sergey Grinev