Reputation: 1029
How to add tooltip for table column or row?
UPD:
I have a table. And I want to add tooltip for cell (column) or row like for textfield
Upvotes: 4
Views: 4664
Reputation: 1029
In my case:
mycolumn.setCellFactory(
new Callback<TableColumn<MyModel, String>, TableCell<MyModel, String>>() {
@Override
public TableCell<MyModel,String> call(TableColumn<MyModel,String> tableColumn){
return new TextFieldTableCell<MyModel, String>() {
@Override public void updateItem(String string, boolean isEmpty) {
super.updateItem(string, isEmpty);
if (!isEmpty) {
MyModel model =
getTableView().getItems().get(getTableRow().getIndex());
Tooltip tip = new Tooltip(model.getTip());
setTooltip(tip);
}
}
};
}});
Upvotes: 2