2017-08-25 4 views
0

J'ai une instance TableView et certaines colonnes contiennent des ComboBoxes.Comment obtenir ComboBox à partir de TableView?

private TableView<ScheduleLecture> tableSchedule; 
private TableColumn<ScheduleLecture, DayOfWeek> colDay; 

private void initialize() { 
colDay.setCellValueFactory(new PropertyValueFactory<>("day")); 
colDay.setCellFactory(ComboBoxTableCell.forTableColumn(DayOfWeek.values())); 

Je dois développer ComboBox de TableCell quand est focalisé.

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] 
      } 
     } 
    } 
} 

Comment puis-je le faire?

Répondre