List of usage examples for javafx.scene.layout GridPane GridPane
public GridPane()
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Borders"); 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 ww. jav a2 s . co m*/ gridpane.setVgap(10); final TextArea cssEditorFld = new TextArea(); cssEditorFld.setPrefRowCount(10); cssEditorFld.setPrefColumnCount(100); cssEditorFld.setWrapText(true); cssEditorFld.setPrefWidth(150); GridPane.setHalignment(cssEditorFld, HPos.CENTER); gridpane.add(cssEditorFld, 0, 1); String cssDefault = "line1;\nline2;\n"; cssEditorFld.setText(cssDefault); root.getChildren().add(gridpane); 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 ww . ja v a 2 s . c om gridpane.setVgap(10); Label label = new Label("Label"); GridPane.setHalignment(label, HPos.CENTER); gridpane.add(label, 0, 0); root.getChildren().add(gridpane); 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 ava2 s. c o m gridpane.setVgap(10); final ImageView imv = new ImageView(); 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("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 ww. 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) { 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 www .j a va2s. 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("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);/* w ww. j a v a 2 s. c o m*/ gridpane.setVgap(10); final ImageView imv = new ImageView(); final Image image2 = new Image(Main.class.getResourceAsStream("a.jpg")); imv.setImage(image2); imv.setEffect(new SepiaTone()); // default is full (1.0) effect 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 stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> emailComboBox = new ComboBox<String>(); emailComboBox.getItems().addAll("A", "B", "C", "D", "E"); emailComboBox.setValue("A"); System.out.println(emailComboBox.getValue()); GridPane grid = new GridPane(); grid.setVgap(4);// w w w . ja v a2s . c o m 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
private GridPane createGridPane() { GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(5);// w ww .j ava2s .c om gridpane.setVgap(5); ColumnConstraints column1 = new ColumnConstraints(100); ColumnConstraints column2 = new ColumnConstraints(50, 150, 300); column2.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2); Label fNameLbl = new Label("First Name"); TextField fNameFld = new TextField(); Label lNameLbl = new Label("Last Name"); TextField lNameFld = new TextField(); Button saveButton = new Button("Save"); GridPane.setHalignment(fNameLbl, HPos.RIGHT); GridPane.setHalignment(lNameLbl, HPos.RIGHT); GridPane.setHalignment(fNameFld, HPos.LEFT); GridPane.setHalignment(lNameFld, HPos.LEFT); GridPane.setHalignment(saveButton, HPos.RIGHT); gridpane.add(fNameLbl, 0, 0); gridpane.add(fNameFld, 1, 0); gridpane.add(lNameLbl, 0, 1); gridpane.add(lNameFld, 1, 1); gridpane.add(saveButton, 1, 2); return gridpane; }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("TitledPane"); Scene scene = new Scene(new Group(), 450, 250); scene.setFill(Color.GHOSTWHITE); TitledPane gridTitlePane = new TitledPane(); GridPane grid = new GridPane(); grid.setVgap(4);// ww w.ja v a 2 s.c o m grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(new TextField(), 1, 0); grid.add(new Label("Cc: "), 0, 1); grid.add(new TextField(), 1, 1); grid.add(new Label("Subject: "), 0, 2); grid.add(new TextField(), 1, 2); grid.add(new Label("Attachment: "), 0, 3); grid.add(new Label("static value"), 1, 3); gridTitlePane.setText("Grid"); gridTitlePane.setContent(grid); HBox hbox = new HBox(10); hbox.setPadding(new Insets(20, 0, 0, 20)); hbox.getChildren().setAll(gridTitlePane); Group root = (Group) scene.getRoot(); root.getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Color> cmb = new ComboBox<Color>(); cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE); cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() { @Override/*from w w w . j a v a 2 s .c om*/ public ListCell<Color> call(ListView<Color> p) { return new ListCell<Color>() { private final Rectangle rectangle; { setContentDisplay(ContentDisplay.GRAPHIC_ONLY); rectangle = new Rectangle(10, 10); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { rectangle.setFill(item); setGraphic(rectangle); } } }; } }); gridpane.add(cmb, 2, 0); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }