StackPane_AbsoluteLayout1 |
|
|
Code :
package javafxtemplate2; import javafx.application.Application; import javafx.scene.*; import javafx.scene.control.Label; import javafx.scene.layout.Pane; 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(10);caption.setTranslateY(20); Line line = new Line(90, 40, 230, 40); line.setStroke(Color.BLACK); Circle circle = new Circle(130, 130, 30); circle.setFill(Color.CHOCOLATE); Pane proot = new Pane(); //StackPane proot = new StackPane(); proot.getChildren() .addAll(caption,rect, line, circle); Scene scene = new Scene (proot, 250, 220, Color.WHITESMOKE); primaryStage.setTitle ("Absolute layout"); // primaryStage.setTitle //("Stack Overrides Absolute layout"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } |
Runtime as Pane: Pane proot = new Pane(); Runtime as StackPane: //Pane proot = new Pane(); |