2

here's my interesting situation,

I am trying to access a Combobox from a Tableview which has a column containing a cellfactory of ComboBoxTableCell. This will be accessed through an event handler such that when a user hits 'enter' on the row, the combobox will show its items.

The ComboboxTableCell was created as

tableViewCol.setCellFactory(ComboBoxTableCell.forTableColumn(anObservableArrayList));

The tableview which I could access is referenced as:

@FXML
private TableView<Obj> tableView;
@FXML
private TableColumn<Obj, String> tableViewCol;

The furthest I was able to get was the tablecol following these paths whose .getClass() resulted with: "class javafx.scene.control.TableColumn$1":

tableView.getSelectionModel().getSelectedCells().get(0).getTableColumn().getCellFactory().call()

tableView.getSelectionModel().getSelectedCells().get(0).getTableColumn().cellFactoryProperty()

Once again, I'm trying to access a selected row in a tableview whose column has a ComboBoxTableCell and I'm trying to have the selected row's comboBox open when an event click, enter happens. I just can't map out how to access it and it's driving me nuts.

For visual rep see first link then second. https://i.stack.imgur.com/teV4S.png https://i.stack.imgur.com/7kjPs.png (Bleh, newbies can't post images).

Any help suggestions, alternatives, feedback are helpful. Thanks!

  • You may construct your own custom comboboxcell based on the cell item, then when the 'enter' is invoked you open the combobox in startEdit(). See [this similar approach](http://stackoverflow.com/questions/29387386/populate-combo-box-list-dynamically-for-each-row-in-javafx-table-view/29390823#29390823) – Uluk Biy Apr 02 '15 at 06:39

1 Answers1

0

You can access the Comobobx over cell.getGraphic().

But do something like this:

    tableView.edit(tableView.getSelectionModel().getSelectedIndex(), tableViewCol);

and this everytime the Selection changed.

If you want you can write your own Comboboxcell with automatic shows its Graphic when its row is selected.

Marcel
  • 1,606
  • 16
  • 29