JavaFX Properties in TableView

One somewhat strange part of the property API is that IntegerProperty implements ObservableValue<Number>, not ObservableValue<Integer>. So, somewhat counterintuitively, you need TableColumn<Person, Number> ageColumn = new TableColumn<Person, Number>(“Age”); As an aside, and I’m not sure if this causes problems, but it’s more usual to use int instead of Integer for the return type for the get … Read more

How to add button in JavaFX table view

To be able to render the column, TableColumn needs cellValueFactory. But the “action” column does not exist in underlying data model. In this case, I just give some dummy value to cellValueFactory and move on: public class JustDoIt extends Application { private final TableView<Person> table = new TableView<>(); private final ObservableList<Person> data = FXCollections.observableArrayList( new … Read more

Getting selected item from a JavaFX TableView

Ok, lets say you have a data model class named Person. This way: Person person = taview.getSelectionModel().getSelectedItem(); System.out.println(person.getName()); Note that TableView must take a Person as a type argument to avoid casting: @FXML private TableView<Person> taview; or TableView<Person> taview = new TableView<>(); when your row is selected, you will return one Person instance. Then do … Read more

UITableViewAlertForLayoutOutsideViewHierarchy error: Warning once only (iOS 13 GM)

It happened to me because I registered the device for change orientation notification in the viewWillAppear(🙂 method. I moved the registration in the viewDidAppear(🙂 and Xcode it’s not stopping at the breakpoint anymore. What I can say is that layout changes might be run when the view is already visible…

How to add CheckBox’s to a TableView in JavaFX

Uses javafx.scene.control.cell.CheckBoxTableCell<S,T> and the work’s done ! ObservableList< TableColumn< RSSReader, ? >> columns = _rssStreamsView.getColumns(); […] TableColumn< RSSReader, Boolean > loadedColumn = new TableColumn<>( “Loaded” ); loadedColumn.setCellValueFactory( new Callback<CellDataFeatures<RSSReader,Boolean>,ObservableValue<Boolean>>(){ @Override public ObservableValue<Boolean> call( CellDataFeatures<RSSReader,Boolean> p ){ return p.getValue().getCompleted(); }}); loadedColumn.setCellFactory( new Callback<TableColumn<RSSReader,Boolean>,TableCell<RSSReader,Boolean>>(){ @Override public TableCell<RSSReader,Boolean> call( TableColumn<RSSReader,Boolean> p ){ return new CheckBoxTableCell<>(); }}); […] columns.add( … Read more

How to reload tableview from another view controller in swift

You can do this: In your tableView Controller: override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(loadList), name: NSNotification.Name(rawValue: “load”), object: nil) } @objc func loadList(notification: NSNotification){ //load data here self.tableView.reloadData() } Then in the other ViewController : NotificationCenter.default.post(name: NSNotification.Name(rawValue: “load”), object: nil)