List of usage examples for javafx.scene Group getChildren
@Override
public ObservableList<Node> getChildren()
From source file:Main.java
@Override public void start(Stage stage) { root.setExpanded(true);// w w w . ja va 2 s. c o m employees.stream().forEach((employee) -> { root.getChildren().add(new TreeItem<>(employee)); }); Scene scene = new Scene(new Group(), 400, 400); Group sceneRoot = (Group) scene.getRoot(); TreeTableColumn<Employee, String> empColumn = new TreeTableColumn<>("Employee"); empColumn.setPrefWidth(150); empColumn.setCellValueFactory( (TreeTableColumn.CellDataFeatures<Employee, String> param) -> new ReadOnlyStringWrapper( param.getValue().getValue().getName())); TreeTableColumn<Employee, String> emailColumn = new TreeTableColumn<>("Email"); emailColumn.setPrefWidth(190); emailColumn.setCellValueFactory( (TreeTableColumn.CellDataFeatures<Employee, String> param) -> new ReadOnlyStringWrapper( param.getValue().getValue().getEmail())); TreeTableView<Employee> treeTableView = new TreeTableView<>(root); treeTableView.getColumns().setAll(empColumn, emailColumn); treeTableView.setTableMenuButtonVisible(true); sceneRoot.getChildren().add(treeTableView); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Shapes"); Group root = new Group(); Scene scene = new Scene(root, 300, 300, Color.WHITE); Path path = new Path(); QuadCurveTo quadCurveTo = new QuadCurveTo(); quadCurveTo.setX(50);/*w ww. j a v a2s. c om*/ quadCurveTo.setY(50); quadCurveTo.setControlX(10); quadCurveTo.setControlY(50); LineTo lineTo1 = new LineTo(); lineTo1.setX(150); lineTo1.setY(150); LineTo lineTo2 = new LineTo(); lineTo2.setX(100); lineTo2.setY(200); LineTo lineTo3 = new LineTo(); lineTo3.setX(350); lineTo3.setY(150); MoveTo moveTo = new MoveTo(); moveTo.setX(50); moveTo.setY(150); path.getElements().add(moveTo); path.getElements().add(quadCurveTo); path.getElements().add(lineTo1); path.getElements().add(lineTo2); path.getElements().add(lineTo3); path.setTranslateY(30); path.setStrokeWidth(3); path.setStroke(Color.BLACK); root.getChildren().add(path); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Title"); Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); EventHandler<ActionEvent> action = changeTabPlacement(); Menu menu = new Menu("Direction"); MenuItem left = new MenuItem("Left"); left.setOnAction(action);/*w w w.ja v a 2 s. co m*/ menu.getItems().add(left); MenuItem right = new MenuItem("Right"); right.setOnAction(action); menu.getItems().add(right); MenuItem top = new MenuItem("Top"); top.setOnAction(action); menu.getItems().add(top); MenuItem bottom = new MenuItem("Bottom"); bottom.setOnAction(action); menu.getItems().add(bottom); menuBar.getMenus().add(menu); BorderPane borderPane = new BorderPane(); borderPane.prefHeightProperty().bind(scene.heightProperty()); borderPane.prefWidthProperty().bind(scene.widthProperty()); borderPane.setTop(menuBar); root.getChildren().add(borderPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
public MyDialog(Stage owner) { super();//from w ww. j a v a 2 s . c o m initOwner(owner); setTitle("title"); Group root = new Group(); Scene scene = new Scene(root, 250, 150, Color.WHITE); setScene(scene); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(5); gridpane.setVgap(5); Label userNameLbl = new Label("User Name: "); gridpane.add(userNameLbl, 0, 1); Label passwordLbl = new Label("Password: "); gridpane.add(passwordLbl, 0, 2); final TextField userNameFld = new TextField("Admin"); gridpane.add(userNameFld, 1, 1); final PasswordField passwordFld = new PasswordField(); passwordFld.setText("password"); gridpane.add(passwordFld, 1, 2); Button login = new Button("Change"); login.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { close(); } }); gridpane.add(login, 1, 3); GridPane.setHalignment(login, HPos.RIGHT); root.getChildren().add(gridpane); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); final NumberAxis xAxis = new NumberAxis(1, 12, 1); final NumberAxis yAxis = new NumberAxis(); final StackedAreaChart<Number, Number> stackedAreaChart = new StackedAreaChart<Number, Number>(xAxis, yAxis);/* www . j av a 2 s . c o m*/ final XYChart.Series<Number, Number> series1 = new XYChart.Series<Number, Number>(); xAxis.setLabel("Month"); yAxis.setLabel("Value"); stackedAreaChart.setTitle("StackedAreaChart"); series1.setName("XYChart.Series 1"); series1.getData().add(new XYChart.Data(1, 100)); series1.getData().add(new XYChart.Data(2, 200)); series1.getData().add(new XYChart.Data(10, 150)); XYChart.Series<Number, Number> series2 = new XYChart.Series(); series2.setName("XYChart.Series 2"); series2.getData().add(new XYChart.Data(1, 50)); series2.getData().add(new XYChart.Data(2, 200)); series2.getData().add(new XYChart.Data(10, 260)); stackedAreaChart.getData().addAll(series1, series2); root.getChildren().addAll(stackedAreaChart); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("title"); Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); Menu menu = new Menu("File"); ToggleGroup modalGroup = new ToggleGroup(); RadioMenuItem nonModalItem = RadioMenuItemBuilder.create().toggleGroup(modalGroup).text("On").selected(true) .build();// w w w.j a v a2s . com nonModalItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(nonModalItem); RadioMenuItem modalItem = RadioMenuItemBuilder.create().toggleGroup(modalGroup).text("Off").selected(true) .build(); modalItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(modalItem); menu.getItems().add(new SeparatorMenuItem()); menuBar.getMenus().add(menu); root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); xAxis.setCategories(//from www. ja va 2s . c o m FXCollections.<String>observableArrayList(Arrays.asList("January", "February", "March"))); yAxis.setLabel("Value"); final StackedBarChart<String, Number> stackedBarChart = new StackedBarChart<String, Number>(xAxis, yAxis); stackedBarChart.setTitle("StackedBarChart"); XYChart.Series<String, Number> series1 = new XYChart.Series(); series1.setName("XYChart.Series 1"); series1.getData().add(new XYChart.Data("January", 100)); series1.getData().add(new XYChart.Data("February", 200)); series1.getData().add(new XYChart.Data("March", 50)); XYChart.Series<String, Number> series2 = new XYChart.Series(); series2.setName("XYChart.Series 2"); series2.getData().add(new XYChart.Data("January", 150)); series2.getData().add(new XYChart.Data("February", 100)); series2.getData().add(new XYChart.Data("March", 60)); stackedBarChart.getData().addAll(series1, series2); root.getChildren().addAll(stackedBarChart); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Color> cmb = new ComboBox<Color>(); cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE); cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() { @Override/* w ww .j av a 2 s . c om*/ public ListCell<Color> call(ListView<Color> p) { return new ListCell<Color>() { private final Rectangle rectangle; { setContentDisplay(ContentDisplay.GRAPHIC_ONLY); rectangle = new Rectangle(10, 10); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { rectangle.setFill(item); setGraphic(rectangle); } } }; } }); gridpane.add(cmb, 2, 0); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Color> cmb = new ComboBox<Color>(); cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE); cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() { @Override//from ww w .j a va2 s . com public ListCell<Color> call(ListView<Color> p) { return new ListCell<Color>() { private final Rectangle rectangle; { setContentDisplay(ContentDisplay.GRAPHIC_ONLY); rectangle = new Rectangle(10, 10); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { rectangle.setFill(item); setGraphic(rectangle); } } }; } }); gridpane.add(cmb, 2, 0); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { BorderPane root = new BorderPane(); Pane parentContainer = new Pane(); parentContainer.setPrefSize(500, 500); parentContainer.setPickOnBounds(false); //Pane parent = new Pane(); Group parent = new Group(); boundsLayoutNode = parent;// www . j a v a2 s .c o m //parent.setPrefSize(300, 200); parent.setLayoutX(200); parent.setLayoutY(200); parent.setStyle("-fx-background-color:white;"); parent.getChildren().addAll(new Group(localXAxisGroup, localYAxisGroup), new Group(parentXAxisGroup, parentYAxisGroup), new Group(parentBoundsRect, PARENT_BOUNDS_PATH_CIRCLE), new Group(localBoundsRect, LOCAL_BOUNDS_PATH_CIRCLE), new Group(layoutBoundsRect, LAYOUT_BOUNDS_PATH_CIRCLE), new Group(mainRect)); parentContainer.getChildren().addAll(parent); VBox transformsControls = getTransformationControls(); VBox resultsControls = getResultsControls(); BorderPane nestedPane = new BorderPane(); nestedPane.setCenter(parentContainer); nestedPane.setBottom(resultsControls); //nestedPane.setTop(printDataTextArea); //printDataTextArea.setPrefColumnCount(40); //printDataTextArea.setPrefRowCount(3); root.setCenter(nestedPane); root.setRight(transformsControls); //root.setBottom(resultsControls); //root.setCenter(parentContainer); // Attach event handlers attachEventHandlers(); Scene scene = new Scene(root); //, 600, 400); stage.setScene(scene); stage.setTitle("Bounds of a Node"); Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); stage.setX(visualBounds.getMinX()); stage.setY(visualBounds.getMinY()); stage.setWidth(visualBounds.getWidth()); stage.setHeight(visualBounds.getHeight()); stage.show(); // Make sure everything is in sync relayout(); }