0

I am working with javafx tableview.

One of my column is currently having all row as null but I still want it to display it by having null written in those columns.

Any suggestion ?

learner
  • 1,952
  • 7
  • 33
  • 62

1 Answers1

0

You can use setCellFactory() and on the updateItem() methode, you check if item is null and if it's true you write "null"

@Override
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null || empty) {
        setText("null");
        setGraphic(null);
    } else {
       //Things to do if it's not null
    }
}

check that for detail http://www.java2s.com/Code/Java/JavaFX/customcellfactory.htm but for display null just do what I say

agonist_
  • 4,890
  • 6
  • 32
  • 55
  • but it also has some update and a null value might change from null to non null so how to handle it in that case... – learner Jun 25 '13 at 14:25
  • if you change the value of a cell, so in the next updateItem, you will be in the case where item != null, so you juste need to do what you want with the non null value. – agonist_ Jun 25 '13 at 14:36