List of usage examples for javafx.scene.layout VBox setPadding
public final void setPadding(Insets value)
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Simple Search"); TextField txt = new TextField(); txt.setPromptText("Search"); txt.textProperty().addListener(new ChangeListener() { public void changed(ObservableValue observable, Object oldVal, Object newVal) { search((String) oldVal, (String) newVal); }/*w ww .ja v a 2 s .c o m*/ }); list.setMaxHeight(180); for (int i = 0; i < 100; i++) { entries.add("Item " + i); } entries.add("A"); entries.add("B"); entries.add("C"); entries.add("D"); list.setItems(entries); VBox root = new VBox(); root.setPadding(new Insets(10, 10, 10, 10)); root.setSpacing(2); root.getChildren().addAll(txt, list); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); // 5 pixels space between child nodes VBox vbox = new VBox(5); // 1 pixel padding between child nodes only vbox.setPadding(new Insets(1)); Rectangle r1 = new Rectangle(10, 10); Rectangle r2 = new Rectangle(20, 100); Rectangle r3 = new Rectangle(50, 20); Rectangle r4 = new Rectangle(20, 50); HBox.setMargin(r1, new Insets(2, 2, 2, 2)); vbox.getChildren().addAll(r1, r2, r3, r4); root.getChildren().add(vbox);/*from w w w. j ava 2 s. c om*/ 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 w w w.j a v a 2s. com stage.setTitle("Password Field Sample"); VBox vb = new VBox(); vb.setPadding(new Insets(10, 0, 0, 10)); vb.setSpacing(10); HBox hb = new HBox(); hb.setSpacing(10); hb.setAlignment(Pos.CENTER_LEFT); Label label = new Label("Password"); final PasswordField pb = new PasswordField(); pb.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (!pb.getText().equals("abc")) { message.setText("Your password is incorrect!"); message.setTextFill(Color.web("red")); } else { message.setText("Your password has been confirmed"); message.setTextFill(Color.web("black")); } pb.setText(""); } }); hb.getChildren().addAll(label, pb); vb.getChildren().addAll(hb, message); scene.setRoot(vb); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(450);// www . j ava 2s. co m stage.setHeight(550); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); firstNameCol.setSortType(TableColumn.SortType.DESCENDING); lastNameCol.setSortable(false); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(450);/*w w w .j a va2 s . c o m*/ stage.setHeight(550); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); final Button addButton = new Button("Add"); addButton.setOnAction((ActionEvent e) -> { data.add(new Person("Z", "X")); }); hb.getChildren().addAll(addButton); hb.setSpacing(3); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table, hb); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(450);//from w ww . j a v a2 s . c o m stage.setHeight(550); table.setEditable(true); TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); firstNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn()); firstNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> { ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue()); }); TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); lastNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn()); lastNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> { ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue()); }); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(400);//w ww . j av a 2 s. c o m stage.setHeight(550); table.setEditable(true); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName")); TableColumn emailCol = new TableColumn("Email"); emailCol.setMinWidth(200); emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol, emailCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(400);/* www .ja v a 2 s . c om*/ stage.setHeight(550); table.setEditable(true); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName")); TableColumn emailCol = new TableColumn("Email"); emailCol.setMinWidth(200); emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol, emailCol); final Button addButton = new Button("Add"); addButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { data.add(new Person("new", "new", "new")); } }); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table, addButton); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:com.thomaskuenneth.openweathermapweather.BasicView.java
public BasicView(String name) { super(name);/*from w ww . ja va 2 s . co m*/ bundle = ResourceBundle.getBundle("com.thomaskuenneth.openweathermapweather.strings"); city = new TextField(); city.setFloatText(bundle.getString("hint")); Button show = new Button(bundle.getString("anzeigen")); image = new ImageView(); temperatur = new Text(); beschreibung = new Text(); VBox texts = new VBox(temperatur, beschreibung); HBox hb1 = new HBox(10, image, texts); hb1.setPadding(new Insets(10, 0, 0, 0)); hb1.setAlignment(Pos.TOP_LEFT); show.setOnAction(e -> doIt()); VBox controls = new VBox(10, city, show, hb1); controls.setPadding(new Insets(14, 14, 14, 14)); controls.setAlignment(Pos.TOP_LEFT); setCenter(controls); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); stage.setWidth(300);/* w w w . j a v a 2 s . c o m*/ stage.setHeight(500); final Label label = new Label("Student IDs"); label.setFont(new Font("Arial", 20)); TableColumn<Map, String> firstDataColumn = new TableColumn<>("Class A"); TableColumn<Map, String> secondDataColumn = new TableColumn<>("Class B"); firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); firstDataColumn.setMinWidth(130); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); secondDataColumn.setMinWidth(130); TableView tableView = new TableView<>(generateDataInMap()); tableView.setEditable(true); tableView.getSelectionModel().setCellSelectionEnabled(true); tableView.getColumns().setAll(firstDataColumn, secondDataColumn); Callback<TableColumn<Map, String>, TableCell<Map, String>> cellFactoryForMap = ( TableColumn<Map, String> p) -> new TextFieldTableCell(new StringConverter() { @Override public String toString(Object t) { return t.toString(); } @Override public Object fromString(String string) { return string; } }); firstDataColumn.setCellFactory(cellFactoryForMap); secondDataColumn.setCellFactory(cellFactoryForMap); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(label, tableView); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }