List of usage examples for javafx.scene Group Group
public Group()
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); Ellipse bigCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(50).radiusY(75 / 2) .strokeWidth(3).stroke(Color.BLACK).fill(Color.WHITE).build(); Ellipse smallCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(35 / 2).radiusY(25 / 2) .build();/*from w w w. j a v a 2 s.c o m*/ Shape shape = Path.subtract(bigCircle, smallCircle); shape.setStrokeWidth(1); shape.setStroke(Color.BLACK); shape.setFill(Color.rgb(255, 200, 0)); DropShadow dropShadow = DropShadowBuilder.create().offsetX(2.0f).offsetY(2.0f) .color(Color.rgb(50, 50, 50, .588)).build(); shape.setEffect(dropShadow); root.getChildren().add(shape); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
License:asdf
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); TilePane tile = new TilePane(Orientation.VERTICAL, 0.5, 0.5); tile.setHgap(8);//from w w w. j a v a 2 s. c om tile.setPrefColumns(4); for (int i = 0; i < 20; i++) { tile.getChildren().add(new CheckBox("asdf")); } HBox hbox = new HBox(10); hbox.setPadding(new Insets(20, 0, 0, 20)); hbox.getChildren().setAll(tile); Group root = (Group) scene.getRoot(); root.getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 200, 200); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override//from www . j a v a 2 s. 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; } }); 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) { stage.setTitle("HTML"); stage.setWidth(500);/*from w w w. j a v a 2s .c o m*/ stage.setHeight(500); Scene scene = new Scene(new Group()); VBox root = new VBox(); Hyperlink hpl = new Hyperlink("java2s.com"); hpl.setFont(Font.font("Arial", 14)); root.getChildren().addAll(hpl); scene.setRoot(root); stage.setScene(scene); stage.show(); }
From source file:Main.java
License:asdf
@Override public void start(Stage stage) { stage.setTitle("TitledPane"); Scene scene = new Scene(new Group(), 450, 250); scene.setFill(Color.GHOSTWHITE); TilePane tile = new TilePane(); tile.setHgap(8);//from ww w. ja v a2 s. c om tile.setPrefColumns(4); for (int i = 0; i < 20; i++) { tile.getChildren().add(new CheckBox("asdf")); } HBox hbox = new HBox(10); hbox.setPadding(new Insets(20, 0, 0, 20)); hbox.getChildren().setAll(tile); Group root = (Group) scene.getRoot(); root.getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
License:asdf
@Override public void start(Stage stage) { stage.setTitle("TitledPane"); Scene scene = new Scene(new Group(), 450, 250); scene.setFill(Color.GHOSTWHITE); TilePane tile = new TilePane(0.3, 0.5); tile.setHgap(8);//from ww w.j a v a 2 s .c o m tile.setPrefColumns(4); for (int i = 0; i < 20; i++) { tile.getChildren().add(new CheckBox("asdf")); } HBox hbox = new HBox(10); hbox.setPadding(new Insets(20, 0, 0, 20)); hbox.getChildren().setAll(tile); Group root = (Group) scene.getRoot(); root.getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("HTML"); stage.setWidth(500);// ww w. j a v a 2s . com stage.setHeight(500); Scene scene = new Scene(new Group()); VBox root = new VBox(); Hyperlink hpl = new Hyperlink("java2s.com"); Image image1 = new Image(new File("a.jpg").toURI().toString(), 0, 100, false, false); hpl.setFont(Font.font("Arial", 14)); hpl.setGraphic(new ImageView(image1)); root.getChildren().addAll(hpl); scene.setRoot(root); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); Text t = new Text(); t.setX(10.0);//from ww w .j a va 2s .c o m t.setY(50.0); t.setCache(true); t.setText("Reflections on JavaFX..."); t.setFill(Color.RED); t.setFont(Font.font(null, FontWeight.BOLD, 30)); Reflection r = new Reflection(); r.setFraction(0.7); t.setEffect(r); root.getChildren().add(t); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); final Rectangle rect = new Rectangle(); rect.setWidth(100);/*w ww . j av a 2 s .c om*/ rect.setHeight(100); root.getChildren().add(rect); rect.setOnTouchPressed(new EventHandler<TouchEvent>() { @Override public void handle(TouchEvent event) { if (touchId == -1) { touchId = event.getTouchPoint().getId(); touchx = event.getTouchPoint().getSceneX() - rect.getTranslateX(); touchy = event.getTouchPoint().getSceneY() - rect.getTranslateY(); } event.consume(); } }); rect.setOnTouchReleased(new EventHandler<TouchEvent>() { @Override public void handle(TouchEvent event) { if (event.getTouchPoint().getId() == touchId) { touchId = -1; } event.consume(); } }); rect.setOnTouchMoved(new EventHandler<TouchEvent>() { @Override public void handle(TouchEvent event) { if (event.getTouchPoint().getId() == touchId) { rect.setTranslateX(event.getTouchPoint().getSceneX() - touchx); rect.setTranslateY(event.getTouchPoint().getSceneY() - touchy); } event.consume(); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Button Sample"); stage.setWidth(300);/*from w w w . j a v a2s . c om*/ stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); Image image = new Image(getClass().getResourceAsStream("a.png")); Button button1 = new Button("Accept", new ImageView(image)); button1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Accepted"); } }); vbox.getChildren().add(button1); vbox.setSpacing(10); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }