0
私はTableViewインスタンスを持っていて、いくつかのカラムにはComboBoxesが含まれています。TableViewからComboBoxを取得するには?
private TableView<ScheduleLecture> tableSchedule;
private TableColumn<ScheduleLecture, DayOfWeek> colDay;
private void initialize() {
colDay.setCellValueFactory(new PropertyValueFactory<>("day"));
colDay.setCellFactory(ComboBoxTableCell.forTableColumn(DayOfWeek.values()));
フォーカスが当てられている場合は、TableCellのComboBoxを展開する必要があります。
public void onTableMouseClicked(MouseEvent event) {
if (tableSchedule.getEditingCell() == null) {
int row = tableSchedule.getSelectionModel().getFocusedIndex();
ObservableList<TablePosition> selectedCells = tableSchedule.getSelectionModel().getSelectedCells();
if(selectedCells.size() == 0){
return;
}
TableColumn col = selectedCells.get(0).getTableColumn();
tableSchedule.edit(row, col);
Object cellData = col.getCellData(0);
if(cellData instanceof Enum){
if(cellData instanceof DayOfWeek){
//comboBox.show(); for cell [row, col.index]
}
}
}
}
どうすればいいですか?