StackPane_VBox1 |
In this example controls in a StackPane were further arranged by VBox, (See StackPane_AbsoluteLayout1.htm) |
Code :
package javafxtemplate2; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; /** * * @author Manas9 */ public class JavaFXTemplate2 extends Application { @Override public void start(Stage primaryStage) { Rectangle rect = new Rectangle(25, 25, 50, 50); rect.setFill(Color.CADETBLUE); Label caption = new Label("Label1"); caption.setTranslateX(5);caption.setTranslateY(20); Line line = new Line(90, 40, 230, 50); line.setStroke(Color.BLACK); //circle x,y , radius Circle circle = new Circle(130, 130, 20); circle.setFill(Color.CHOCOLATE); VBox vbox1 = new VBox(); vbox1.setPrefWidth(200);vbox1.setSpacing(20); vbox1.setPadding(new Insets(0, 20, 10, 20)); vbox1.getChildren().addAll(caption,rect,circle,line); //Pane proot = new Pane(); StackPane proot = new StackPane(); proot.getChildren().add(vbox1); proot.setAlignment(Pos.CENTER); Scene scene = new Scene(proot, 250, 220, Color.WHITESMOKE); //primaryStage.setTitle("Absolute layout"); primaryStage.setTitle("Stack Pane::VBox "); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } |
Without VBox and formating
|
![]() |