Alex
Alex

Reputation: 1029

How to add tooltip for table column?

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 example

Upvotes: 4

Views: 4664

Answers (2)

Alex
Alex

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

Gaurav
Gaurav

Reputation: 1567

The tooltip can be set by calling setToolTip method.

Upvotes: 1

Related Questions