我在我的TableView中有一個ComboBoxTableCell,當有人單擊ComboBoxTableCell時,我希望另一個窗格顯示在具有項目列表的ComboBoxTableCell下面。我試圖獲得ComboBoxTableCell的座標,但沒有運氣。有什麼方法可以獲得座標嗎?或者你有更好的方法來做到這一點?下面是示例UI的圖像,我想要完成。謝謝。如何獲取TableView JavaFX中TableCell的X和Y座標?
這裏是我的方法來初始化的TableView
私人無效initOrderTable(){
this.orderTable.setEditable(true);
TableColumn nameCol = new TableColumn("Name");
nameCol.setMinWidth(100);
nameCol.setCellValueFactory(
new PropertyValueFactory<>("name"));
nameCol.setCellFactory(new Callback<TableColumn<Product, String>,ComboBoxTableCell<Product,String>>() {
@Override
public ComboBoxTableCell<Product, String> call(TableColumn<Product, String> param) {
ComboBoxTableCell ct= new ComboBoxTableCell<>();
ct.setComboBoxEditable(true);
return ct;
}
});
this.orderTable.getItems().addAll("Sample Row");
this.orderTable.getColumns().addAll(nameCol);
}
你能顯示一些代碼嗎? – 2014-11-22 13:55:19