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) { Scene scene = new Scene(new Group(), 450, 250); TextField notification = new TextField(); MenuItem item1 = new MenuItem("About"); item1.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { System.out.println("About"); }//from ww w. ja v a 2s . c om }); MenuItem item2 = new MenuItem("Preferences"); item2.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { System.out.println("Preferences"); } }); final ContextMenu contextMenu = new ContextMenu(item1, item2); contextMenu.setOnShowing(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { System.out.println("showing"); } }); contextMenu.setOnShown(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { System.out.println("shown"); } }); System.out.println(contextMenu.onActionProperty()); contextMenu.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { System.out.println("on"); } }); notification.setContextMenu(contextMenu); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(notification, 1, 0); contextMenu.show(grid, Side.BOTTOM, 20, 20); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("ComboBoxSample"); Scene scene = new Scene(new Group(), 450, 250); ComboBox emailComboBox = new ComboBox(); emailComboBox.getItems().addAll("A", "B", "C", "D", "E"); emailComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override//ww w. j a v a 2s . c o m public ListCell<String> call(ListView<String> param) { final ListCell<String> cell = new ListCell<String>() { { super.setPrefWidth(100); } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item); if (item.contains("A")) { setTextFill(Color.RED); } else if (item.contains("B")) { setTextFill(Color.GREEN); } else { setTextFill(Color.BLACK); } } else { setText(null); } } }; return cell; } }); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group group = new Group(); Button button = new Button("Button"); button.setStyle("-fx-font-size: 14px;"); group.getChildren().add(button); Scene scene = new Scene(group, 300, 200); primaryStage.setScene(scene);/* w ww. ja v a 2 s. c o m*/ primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group group = new Group(); Button button = new Button("Button"); button.setStyle("-fx-padding: 10 20 10 20;"); group.getChildren().add(button); Scene scene = new Scene(group, 300, 200); primaryStage.setScene(scene);/*from w w w . j a va 2 s. co m*/ primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 200); stage.setScene(scene);/*from www.j a v a 2 s . co m*/ ScrollBar s1 = new ScrollBar(); root.getChildren().add(s1); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);//ww w .ja v a 2 s . c o m Group g = new Group(); Polygon polygon = new Polygon(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, 20.0, 10.0, 10.0, 20.0 }); g.getChildren().add(polygon); scene.setRoot(g); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group group = new Group(); Rectangle rect = new Rectangle(20, 20, 200, 200); rect.setStrokeWidth(2);/*from w w w . ja v a2 s .c o m*/ rect.setStroke(Color.RED); group.getChildren().add(rect); Scene scene = new Scene(group, 300, 200); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);/*from w ww.j ava 2 s . c o m*/ Group g = new Group(); Polyline polyline = new Polyline(); polyline.getPoints().addAll(new Double[] { 0.0, 0.0, 20.0, 10.0, 10.0, 20.0 }); g.getChildren().add(polyline); scene.setRoot(g); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group group = new Group(); Scene scene = new Scene(group); StackPane stack = new StackPane(); stack.getChildren().addAll(new Rectangle(100, 100, Color.BLUE)); group.getChildren().add(stack); stage.setTitle("Welcome to JavaFX!"); stage.setScene(scene);/* www . j av a 2 s . c o m*/ stage.sizeToScene(); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group group = new Group(); Rectangle rect = new Rectangle(20, 20, 200, 200); rect.setArcHeight(15);//from www . ja va2 s . c o m rect.setArcWidth(15); rect.setStroke(Color.BLACK); group.getChildren().add(rect); Scene scene = new Scene(group, 300, 200); primaryStage.setScene(scene); primaryStage.show(); }