Button configure = new Button("Configure"); changeBackgroundOnHoverUsingBinding(configure); Button update = new Button("Update"); changeBackgroundOnHoverUsingEvents(update); layout.setStyle("-fx-padding: 10;"); layout.getChildren().addAll(configure, update); stage.setScene(new Scene(layout)); stage.show(); .when(node.hoverProperty()) .then( new SimpleStringProperty(HOVERED_BUTTON_STYLE) new SimpleStringProperty(STANDARD_BUTTON_STYLE)
public String getSrc() { return this.src.get(); }
public void setDepartment(String firstName) { department.set(firstName); } }
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); TableView<Person> table = new TableView<Person>(); stage.setTitle("Table View Sample"); stage.setWidth(300); stage.setHeight(500); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); TableColumn<Person, String> firstNameCol = new TableColumn<Person, String>("Test Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("name")); table.itemsProperty().get().add(new Person("Dieter")); ((Group) scene.getRoot()).getChildren().addAll(vbox); final StringProperty name = new SimpleStringProperty();
private TableView<Person> table = new TableView<Person>(); private final ObservableList<Person> data = FXCollections.observableArrayList(); private void initData() { initData(); stage.setTitle("Table View Sample"); stage.setWidth(450); stage.setHeight(500); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); table.setPrefHeight(300); final Button removeRowButton = new Button("Remove first row from the table"); removeRowButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { vbox.getChildren().addAll(label, table, setEmailButton, removeRowButton, resetButton); stage.setScene(new Scene(new Group(vbox))); stage.show(); this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email);
TableColumn<Map.Entry<String, String>, String> column1 = new TableColumn<>("Key"); column1.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map.Entry<String, String>, String>, ObservableValue<String>>() { return new SimpleStringProperty(p.getValue().getKey()); TableColumn<Map.Entry<String, String>, String> column2 = new TableColumn<>("Value"); column2.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map.Entry<String, String>, String>, ObservableValue<String>>() { public ObservableValue<String> call(TableColumn.CellDataFeatures<Map.Entry<String, String>, String> p) { return new SimpleStringProperty(p.getValue().getValue()); final TableView<Map.Entry<String,String>> table = new TableView<>(items); stage.setScene(scene); stage.show();
stage.setTitle("Table View Sample"); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); final Label actionTaken = new Label(); new PropertyValueFactory<Person, String>("email")); VBox.setVgrow(table, Priority.ALWAYS); stage.setScene(new Scene(vbox)); stage.show(); this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email); this.likes = new SimpleStringProperty(likes); return firstName.get(); firstName.set(fName); return lastName.get(); lastName.set(fName);
private TableView<Person> table = new TableView<Person>(); private final ObservableList<Person> data = FXCollections.observableArrayList( public void start(Stage stage) { TableColumn<Person, String> firstNameCol = new TableColumn<Person, String>("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName")); item1.setOnAction(e -> System.out.println("Clicked: " + e)); vbox.getChildren().addAll( table); ((Group) scene.getRoot()).getChildren().addAll(vbox); this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email); return firstName.get(); firstName.set(fName); return lastName.get(); lastName.set(fName);
Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); firstNameCol.getStyleClass().add("left-header"); lastNameCol.getStyleClass().add("bleed-header"); Label headerLabel = new Label("Long Last Name"); vbox.getChildren().addAll(label, table); ((Group) scene.getRoot()).getChildren().addAll(vbox); scene.getStylesheets().add(getClass().getResource("bleed.css").toExternalForm()); this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email); return firstName.get(); firstName.set(fName); return lastName.get(); lastName.set(fName);
public void start( Stage stage ) stage.setWidth( 450 ); stage.setHeight( 500 ); final Button btn = new Button( "Just Do It" ); table.getColumns().addAll( firstNameCol, lastNameCol, actionCol ); Scene scene = new Scene( new Group() ); (( Group ) scene.getRoot()).getChildren().addAll( table ); stage.setScene( scene ); stage.show(); this.firstName = new SimpleStringProperty( fName ); this.lastName = new SimpleStringProperty( lName ); return firstName.get(); firstName.set( fName ); return lastName.get(); lastName.set( fName );
final Label lblTool = new Label(); final TableView<TableProps> table = new TableView<>(); TableColumn<TableProps, String> clmTool = new TableColumn<>("Tool"); clmTool.setMinWidth(160); clmTool.setCellValueFactory(new PropertyValueFactory<>("tool")); TableColumn<TableProps, String> clmChart = new TableColumn<>("Chart"); clmChart.setMinWidth(160); clmChart.setCellValueFactory(new PropertyValueFactory<>("chart")); lblTool.setText(newValue.getTool()); pane.setTop(hBox); pane.setCenter(table); stage.setScene(new Scene(pane, 640, 480)); stage.show(); this.tool = new SimpleStringProperty(tool); this.chart = new SimpleStringProperty(chart);
tableView.setItems(sorted); TableColumn<LineItem,String> descCol = new TableColumn<>("desc"); descCol.setCellValueFactory(new PropertyValueFactory<>("desc")); TableColumn<LineItem, Double> amountCol = new TableColumn<>("amount"); amountCol.setCellValueFactory(new PropertyValueFactory<>("amount")); Label label = new Label("click a row"); tableView.setRowFactory(tv -> { TableRow<ObservableList> row = new TableRow<>(); row.setOnMouseClicked(event -> { if (event.getClickCount() == 2 && (!row.isEmpty())) { label.setText(tableView.getSelectionModel().getSelectedIndex() +" <-tbl row, idx in items-> " +items.indexOf(tableView.getSelectionModel().getSelectedItem())); stage.setScene(new Scene(new VBox(5,tableView,label),300,300)); stage.show(); private final StringProperty desc = new SimpleStringProperty(); private final IntegerProperty amount = new SimpleIntegerProperty();
vbox.setAlignment(Pos.CENTER); TableColumn<ObservableList<String>, String> studentIDCol = new TableColumn<>("Student ID"); studentIDCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ObservableList<String>,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ObservableList<String>, String> cdf) { return new SimpleStringProperty(cdf.getValue().get(0)); TableColumn<ObservableList<String>, String> nameCol = new TableColumn<>("Name"); nameCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ObservableList<String>,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ObservableList<String>, String> cdf) { return new SimpleStringProperty(cdf.getValue().get(1)); TableColumn<ObservableList<String>, String> addressCol = new TableColumn<>("Address"); addressCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ObservableList<String>,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ObservableList<String>, String> cdf) { return new SimpleStringProperty(cdf.getValue().get(2)); @Override public ObservableValue<String> call(CellDataFeatures<ObservableList<String>, String> cdf) { return new SimpleStringProperty(cdf.getValue().get(3)); @Override public ObservableValue<String> call(CellDataFeatures<ObservableList<String>, String> cdf) { return new SimpleStringProperty(cdf.getValue().get(4));
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Pets"); stage.setWidth(200); stage.setHeight(200); TableView<Pet> table = new TableView<Pet>(); table.getColumns().addAll(name, owner); ((Group) scene.getRoot()).getChildren().addAll(table); scene.getStylesheets().add("styles/styles.css"); stage.setScene(scene); this.name = new SimpleStringProperty(name); this.owner = new SimpleStringProperty(owner);
public void start(Stage primaryStage) { TableView<Item> table = new TableView<>(); table.setEditable(true); table.getItems()); Label totalLabel = new Label(); totalLabel.textProperty().bind(Bindings.format("Total: %d", total)); Button add = new Button("Add item"); add.setOnAction(e -> table.getItems().add(new Item("New Item", table.getItems().size() + 1))); Button remove = new Button("Remove"); remove.disableProperty().bind( Bindings.isEmpty(table.getSelectionModel().getSelectedItems())); primaryStage.setScene(scene); primaryStage.show(); TableColumn<S,T> col = new TableColumn<>(title); col.setCellValueFactory(cellData -> property.apply(cellData.getValue())); private final StringProperty name = new SimpleStringProperty(); private final IntegerProperty value = new SimpleIntegerProperty();
private TableView<Person> table = new TableView<>(); private final ObservableList<Person> data = FXCollections.observableArrayList( Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); firstNameCol.getStyleClass().add("left-header"); private Label overflowLabel = new Label(); private Group overflowGroup = new Group(overflowLabel); this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email); return firstName.get(); firstName.set(fName); return lastName.get(); lastName.set(fName);
@Override public void start(Stage primaryStage) throws Exception { StringProperty property = new SimpleStringProperty("da content"); primaryStage.setScene(new Scene(vbox5( label(property), hbox5(label("Normal"), textField(property)), hbox5(label("Delayed 1"), textFieldDelayed(property)), hbox5(label("Delayed 2"), textFieldDelayed(property)) ), 800, 600)); primaryStage.show(); } }
new Label("Parallel Execution"), new Label("------------------") ); DoubleBinding parallelProgress = fetchFirstLines(messages, parallelFirstLineExecutor); new Label("Sequential Execution"), new Label("--------------------") ); stage.setScene(new Scene(messages, 600, 650)); stage.show(); private StringProperty url = new SimpleStringProperty(this, "url"); public final void setUrl(String value) { url.set(value); } public final String getUrl() { return url.get(); }
@Override public StringProperty scan() { SimpleStringProperty simpleStringProperty = new SimpleStringProperty(); scanStage = new Stage(); stackPane.getChildren().add(vbox); scanStage.setScene(new Scene(stackPane, 384, 256)); simpleStringProperty.set(scanText.getText()); scanStage.close(); }; scanText.setOnAction(action);
Button button = new Button("button"); button.setOnAction((actionEvent) -> { primaryStage.setScene(new Scene(new VBox(table, button), 800, 600)); primaryStage.show(); ObservableList<StringProperty> data = FXCollections.observableArrayList(); for( int col=0; col < columns; col++) { data.add(new SimpleStringProperty(String.valueOf( row + " / " + col))); TableColumn<ObservableList<StringProperty>, String> column = new TableColumn<>(); String title = "Column " + columnIndex; column.setText(title);