List of usage examples for javafx.scene Scene getRoot
public final Parent getRoot()
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new HBox(20), 400, 100); HBox box = (HBox) scene.getRoot(); final ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(Color.RED); final Text text = new Text("Color picker:"); text.setFill(colorPicker.getValue());/*from www . j a v a 2s.co m*/ colorPicker.setOnAction((ActionEvent t) -> { text.setFill(colorPicker.getValue()); }); box.getChildren().addAll(colorPicker, text); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final Scene scene = new Scene(new Group(), 200, 400); Group sceneRoot = (Group) scene.getRoot(); TreeItem<String> childNode1 = new TreeItem<>("Node 1"); TreeItem<String> childNode2 = new TreeItem<>("Node 2"); TreeItem<String> childNode3 = new TreeItem<>("Node 3"); TreeItem<String> root = new TreeItem<>("Root"); root.setExpanded(true);// w w w . j a v a2 s. c o m root.getChildren().setAll(childNode1, childNode2, childNode3); TreeTableColumn<String, String> column = new TreeTableColumn<>("Column"); column.setPrefWidth(150); column.setCellValueFactory( (CellDataFeatures<String, String> p) -> new ReadOnlyStringWrapper(p.getValue().getValue())); TreeTableView<String> treeTableView = new TreeTableView<>(root); treeTableView.getColumns().add(column); sceneRoot.getChildren().add(treeTableView); stage.setScene(scene); stage.show(); }
From source file:Main.java
private void addBouncyBall(final Scene scene) { final Circle ball = new Circle(100, 100, 20); final Group root = (Group) scene.getRoot(); root.getChildren().add(ball);//from w ww .ja v a 2s . co m Timeline tl = new Timeline(); tl.setCycleCount(Animation.INDEFINITE); KeyFrame moveBall = new KeyFrame(Duration.seconds(.0200), new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { double xMin = ball.getBoundsInParent().getMinX(); double yMin = ball.getBoundsInParent().getMinY(); double xMax = ball.getBoundsInParent().getMaxX(); double yMax = ball.getBoundsInParent().getMaxY(); if (xMin < 0 || xMax > scene.getWidth()) { dx = dx * -1; } if (yMin < 0 || yMax > scene.getHeight()) { dy = dy * -1; } ball.setTranslateX(ball.getTranslateX() + dx); ball.setTranslateY(ball.getTranslateY() + dy); } }); tl.getKeyFrames().add(moveBall); tl.play(); }
From source file:Main.java
@Override public void start(Stage stage) { root.setExpanded(true);/*from w ww .j a v a 2 s.co 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 stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 200); stage.setScene(scene);/*from w w w . j a v a2s.co m*/ Rectangle rect = new Rectangle(100, 100); rect.setLayoutX(50); rect.setLayoutY(50); rect.setStyle("-fx-fill: red; "); ((Group) scene.getRoot()).getChildren().add(rect); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setEditable(true);/* ww w. j ava 2 s. co m*/ Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox); stage.setScene(scene); stage.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 w ww . j a v a2 s . co m Rectangle rect = new Rectangle(100, 100); rect.setLayoutX(50); rect.setLayoutY(50); rect.setStrokeLineCap(StrokeLineCap.BUTT); ((Group) scene.getRoot()).getChildren().add(rect); stage.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 w ww . jav a 2 s . c o m*/ Rectangle rect = new Rectangle(100, 100); rect.setLayoutX(50); rect.setLayoutY(50); rect.getStrokeDashArray().addAll(1.0, 13.0); ((Group) scene.getRoot()).getChildren().add(rect); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Tooltip Sample"); stage.setWidth(300);//from ww w . j a v a2 s . co m stage.setHeight(150); Button button = new Button("Hover Over Me"); button.setTooltip(new Tooltip("Tooltip for Button")); ((Group) scene.getRoot()).getChildren().add(button); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setValue("A"); System.out.println(myComboBox.getValue()); Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox);/*from w w w . j a va 2 s. c o m*/ stage.setScene(scene); stage.show(); }