List of usage examples for javafx.scene Group getChildren
@Override
public ObservableList<Node> getChildren()
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"); MenuItem exitItem = new MenuItem("Exit", null); exitItem.setMnemonicParsing(true);// w w w. ja va 2s . c o m exitItem.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN)); exitItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { Platform.exit(); } }); menu.getItems().add(exitItem); 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(); Scene scene = new Scene(root, 300, 250); Button btn = new Button(); btn.setText("Hello World"); btn.setOnMouseEntered(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse entered"); }/*from w w w. ja va 2 s . c om*/ }); btn.setOnMouseExited(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse exited"); } }); btn.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse pressed"); } }); root.getChildren().add(btn); 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 ww w . ja v a 2s. c o m Group g = new Group(); PerspectiveTransform pt = new PerspectiveTransform(); pt.setUlx(10.0); pt.setUly(10.0); pt.setUrx(310.0); pt.setUry(40.0); pt.setLrx(310.0); pt.setLry(60.0); pt.setLlx(10.0); pt.setLly(90.0); g.setEffect(pt); g.setCache(true); Rectangle r = new Rectangle(); r.setX(10.0); r.setY(10.0); r.setWidth(280.0); r.setHeight(80.0); r.setFill(Color.BLUE); Text t = new Text(); t.setX(20.0); t.setY(65.0); t.setText("JavaFX"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); g.getChildren().add(r); g.getChildren().add(t); scene.setRoot(g); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Tabs"); Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.WHITE); TabPane tabPane = new TabPane(); BorderPane borderPane = new BorderPane(); for (int i = 0; i < 5; i++) { Tab tab = new Tab(); tab.setText("Tab" + i); HBox hbox = new HBox(); hbox.getChildren().add(new Label("Tab" + i)); hbox.setAlignment(Pos.CENTER);/*from w ww. j av a 2s. c o m*/ tab.setContent(hbox); tabPane.getTabs().add(tab); } // bind to take available space borderPane.prefHeightProperty().bind(scene.heightProperty()); borderPane.prefWidthProperty().bind(scene.widthProperty()); borderPane.setCenter(tabPane); root.getChildren().add(borderPane); primaryStage.setScene(scene); 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"); menu.setOnHidden(new EventHandler<Event>() { @Override// ww w . ja v a2 s .c o m public void handle(Event arg0) { } }); MenuItem newItem = new MenuItem("New", null); newItem.setOnMenuValidation(new EventHandler<Event>() { @Override public void handle(Event arg0) { } }); menu.getItems().add(newItem); 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) { primaryStage.setTitle("Menus"); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); Menu menu = new Menu("File"); final MenuItem aboutMenuItem = MenuItemBuilder.create().text("About") .onAction(new EventHandler<ActionEvent>() { @Override/*w w w . j a v a 2s . co m*/ public void handle(ActionEvent e) { System.out.println("You clicked on About!"); } }).accelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN)).build(); menu.getItems().add(aboutMenuItem); menuBar.getMenus().add(menu); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.getChildren().add(menuBar); 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); TextField textBox = new TextField(); textBox.setPromptText("Write here"); // Define an event filter EventHandler filter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { System.out.println("Filtering out event " + event.getEventType()); event.consume();//from w w w .j ava2 s .c om } }; // Register the same filter for two different nodes scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter); // Register the filter for another event type scene.addEventFilter(KeyEvent.KEY_PRESSED, filter); scene.removeEventFilter(MouseEvent.MOUSE_PRESSED, filter); root.getChildren().add(textBox); primaryStage.setScene(scene); 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"); menu.setOnHiding(new EventHandler<Event>() { @Override//from ww w . jav a2 s .co m public void handle(Event arg0) { } }); MenuItem newItem = new MenuItem("New", null); newItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(newItem); 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(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"); menu.setOnHidden(new EventHandler<Event>() { @Override/*from www . j a va 2s .co m*/ public void handle(Event arg0) { } }); MenuItem newItem = new MenuItem("New", null); newItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(newItem); 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) { 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 2s. c om 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(); }