Difference between VBoxBuilder and VBox in javafx

Can someone explain the difference between VBoxBuilder and VBox in JavaFX?

 VBoxBuilder boxBuilder = VBoxBuilder.create(); VBox vBox1 = new VBox(); 
+4
source share
2 answers

For alternatives to builders and builders

The answer to Sergey answers this question, this is just additional information.

There is a good description of the linker functionality from one of the creators of the JavaFX builder in JavaFX Builders Benefits .

However, as Sergey points out, builders are deprecated from the underlying JavaFX platform . Oracle is busy removing all the builder references from the JavaFX sample code.

Although it is deprecated, linker functionality will be present and supported in JavaFX 8 (this has been a long time).

Some alternatives to using JavaFX Java builders:

  • FXML can be used to provide declarative syntax for development, which is somewhat similar to assemblers.

  • JavaFX wrappers for other languages ​​such as GroovyFX and ScalaFX provide linker-style functionality as part of their core implementations, creating their own internal DSLs to define JavaFX objects.

+3
source

For convenience, collectors are added. They allow you to create JavaFX nodes in a single command without entering a new variable. This is more convenient in some situations.

The following two code snippets give the same result, but the last does not create a temporary variable.

Without a builder:

 VBox vBox = new VBox(); vBox.setAlignment(Pos.CENTER); vBox.getChildren().add(new Label("1")); Scene scene = new Scene(vBox); 

with builder:

 Scene scene2 = new Scene( VBoxBuilder.create().alignment(Pos.CENTER).children(new Label("1")).build()); 

NB:. Although you can refrain from using builders, as recently in an open list of developers' email messages, a problem was raised that could lead to obsolete builders in future releases: http://mail.openjdk.java.net/pipermail/openjfx-dev/2013 -March / 006725.html

+6
source

All Articles