/* * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any */ package test.scenegraph.app; import javafx.application.Application; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class BugAppGrid3 extends Application { Group root = new Group(); private void init(Stage primaryStage) { primaryStage.setScene(new Scene(root)); primaryStage.setHeight(200); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.show(); root.getChildren().add(drawNode()); } GridPane pane; public static Color nodeColors[] = {Color.RED, Color.YELLOW, Color.BLUE, Color.GREEN, Color.BROWN, Color.MAGENTA}; public Node drawNode() { pane = new GridPane(); // if (withStyle) { pane.setStyle("-fx-border-color: darkgray;"); // } pane.setGridLinesVisible(true); Circle c1 = new Circle(8); GridPane.setHalignment(c1,HPos.LEFT); //.LEADING); GridPane.setConstraints(c1, 0, 0); Circle c2 = new Circle(8); GridPane.setConstraints(c2, 0, 1); GridPane.setHalignment(c2,HPos.RIGHT); //.TRAILING Circle c3 = new Circle(8); GridPane.setConstraints(c3, 2, 2); GridPane.setHalignment(c3,HPos.RIGHT); GridPane.setValignment(c3,VPos.BOTTOM); StackPane sp = new StackPane(); sp.setPadding(new Insets(4,4,4,4)); Rectangle b2 = new Rectangle(0, 0, 60, 16); b2.setFill(Color.GREEN); sp.getChildren().add(b2); GridPane.setConstraints(sp, 1, 0,2,2); StackPane sp2 = new StackPane(); sp2.setPadding(new Insets(4,4,4,4)); Rectangle b2a = new Rectangle(0, 0, 16, 60); b2a.setFill(Color.RED); sp2.getChildren().add(b2a); GridPane.setMargin(sp2, new Insets(5,5,5,5)); GridPane.setConstraints(sp2, 0, 0,1,3); Circle c4 = new Circle(8); GridPane.setConstraints(c4, 1, 2); GridPane.setValignment(c4,VPos.TOP); StackPane sp3 = new StackPane(); Pane p0 = new Pane(); p0.setStyle("-fx-border-color: red;"); sp3.setPadding(new Insets(2,2,2,2)); sp3.getChildren().add(p0); Circle c5 = new Circle(8); sp3.getChildren().add(c5); GridPane.setMargin(sp3, new Insets(5,5,5,5)); GridPane.setConstraints(sp3, 1, 3, 2,1, HPos.CENTER, VPos.BASELINE); StackPane sp4 = new StackPane(); Pane p1 = new Pane(); p1.setStyle("-fx-border-color: blue;"); sp4.setPadding(new Insets(2,2,2,2)); sp4.getChildren().add(p1); Circle c6 = new Circle(8); sp4.getChildren().add(c6); GridPane.setConstraints(sp4, 0, 4, 2,1, HPos.LEFT, VPos.CENTER, Priority.SOMETIMES,Priority.SOMETIMES,new Insets(5,5,5,5)); Circle c7 = new Circle(8); GridPane.setConstraints(c7, 2, 4); GridPane.setValignment(c7,VPos.CENTER); pane.getChildren().addAll(c1,c2,c3,c4, sp, sp2); pane.getChildren().add(sp3); pane.getChildren().add(sp4); pane.getChildren().add(c7); return pane; } public static void main(String[] args) { launch(args); } }