List of usage examples for javafx.scene Group getChildren
@Override
public ObservableList<Node> getChildren()
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Title"); Group root = new Group(); Scene scene = new Scene(root, 600, 330, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);// ww w . ja v a 2 s.c o m gridpane.setVgap(10); final ImageView imv = new ImageView(); imv.setFitWidth(100); final Image image2 = new Image(Main.class.getResourceAsStream("button.png")); imv.setImage(image2); final HBox pictureRegion = new HBox(); pictureRegion.getChildren().add(imv); gridpane.add(pictureRegion, 1, 1); root.getChildren().add(gridpane); 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"); textBox.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { System.out.println("Key Pressed: " + ke.getText()); }//from w ww . ja v a 2 s. co m }); textBox.setOnKeyReleased(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { System.out.println("Key Released: " + ke.getText()); } }); root.getChildren().add(textBox); 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, Color.WHITE); TextField field = new TextField() { @Override/*w ww . ja va 2 s . co m*/ public void replaceText(int start, int end, String text) { if (!text.matches("[a-z]")) { super.replaceText(start, end, text); } } @Override public void replaceSelection(String text) { if (!text.matches("[a-z]")) { super.replaceSelection(text); } } }; root.getChildren().add(field); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Colors"); Group root = new Group(); Scene scene = new Scene(root, 350, 300, Color.WHITE); Rectangle rectangle = RectangleBuilder.create().x(50).y(50).width(100).height(70).translateY(10).build(); LinearGradient linearGrad = LinearGradientBuilder.create().startX(50).startY(50).endX(50) .endY(50 + rectangle.prefHeight(-1) + 25).proportional(false).cycleMethod(CycleMethod.NO_CYCLE) .stops(new Stop(0.1f, Color.rgb(255, 200, 0, .784)), new Stop(1.0f, Color.rgb(0, 0, 0, .784))) .build();/*from w w w. j ava 2s .com*/ rectangle.setFill(linearGrad); root.getChildren().add(rectangle); 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, 600, 330, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w w w. j av a 2s. c o m*/ gridpane.setVgap(10); final ImageView imv = new ImageView(); imv.setPreserveRatio(true); final Image image2 = new Image(Main.class.getResourceAsStream("button.png")); imv.setImage(image2); final HBox pictureRegion = new HBox(); pictureRegion.getChildren().add(imv); gridpane.add(pictureRegion, 1, 1); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.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); TextField field = new TextField() { @Override/*from ww w.j a v a2s .co m*/ public void replaceText(int start, int end, String text) { if (!text.matches("[a-z]")) { super.replaceText(start, end, text); } } @Override public void replaceSelection(String text) { if (!text.matches("[a-z]")) { super.replaceSelection(text); } } }; root.getChildren().add(field); 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 tools = new Menu("Your Menu"); Image image = new Image(getClass().getResourceAsStream("a.png")); CheckMenuItem item = new CheckMenuItem("Item 1", new ImageView(image)); tools.getItems().add(item);//from w w w . j a v a2 s. c om tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build()); menuBar.getMenus().add(tools); 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 handler EventHandler handler = new EventHandler<InputEvent>() { public void handle(InputEvent event) { System.out.println("Handling event " + event.getEventType()); event.consume();/*from w ww .j av a2 s . co m*/ } }; scene.addEventHandler(DragEvent.DRAG_EXITED, handler); scene.addEventHandler(MouseEvent.MOUSE_DRAGGED, handler); root.getChildren().add(textBox); 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();// w ww . j a va 2 s . co m Shape shape = Path.subtract(bigCircle, smallCircle); shape.setStrokeWidth(1); shape.setStroke(Color.BLACK); shape.setFill(Color.rgb(255, 200, 0)); root.getChildren().add(shape); 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("Item"); Menu contingencyPlans = new Menu("Submenu"); contingencyPlans.getItems().add(new CheckMenuItem("Item 1")); contingencyPlans.getItems().add(new CheckMenuItem("Item 2")); contingencyPlans.getItems().add(new CheckMenuItem("Item 3")); menu.getItems().add(contingencyPlans); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); menuBar.getMenus().add(menu);//w w w.ja va 2s . c om root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }