1 Reply Latest reply on Sep 20, 2013 2:21 AM by James_D

    Display Image in TableCell



      This might be a problem seen before but I'm really trying to do this by the Book !!

      edit.setCellFactory(new Callback<TableColumn<Object, ImageView>, TableCell<Object, ImageView>>() {
                      public TableCell<Object, ImageView> call(TableColumn<Object, ImageView> param) {
                          TableCell<Object, ImageView> cell = new TableCell<Object, ImageView>() {
                              public void updateItem(ImageView item, boolean empty) {
                                  if (item != null) {
                                      HBox box = new HBox();
                                      VBox vbox = new VBox();
                                      ImageView imageview = new ImageView();
                                      imageview.setImage(new Image(getClass().getResource("edit.png").toExternalForm()));
                                      box.getChildren().addAll(imageview, vbox);
                                      //SETTING ALL THE GRAPHICS COMPONENT FOR CELL
                          return cell;


      when running the program, everything seems to be ok but actually nothing shows up in the tableCell !!

      For some reason, it seems that the declaration of the Callback classes is wrong !!

      All I'm trying is to add an edit icon to the a column that has no data in it !!

        • 1. Re: Display Image in TableCell
          All I'm trying is to add an edit icon to the a column that has no data in it !!

          This might be your problem. If the column has no data, then the item will be null (if I understand you correctly). What is the cell value factory that is set on your column, and what are the items in the table?