0

Please,I'm new in JavaFx ,so go easy for me.I'm using a tableview in my Javafx Application.When there is no data,it displays NO CONTENT IN TABLE. I don't want to set any placeholder,I want at that place set empty rows instead. I tried to give empty values for the columns that contains String,but the Integer and Float Columns,I have to provide real values. This is what,I tried.In the Initialize method.I call this method

   //Initialize second tableview instead of the message NO CONTENT IN THE TABLE
        AddProductsForSale("","","",0f,new Inam());

and the AddProductsForSale method prototype is:

 public void AddProductsForSale(String ref, String exp, String name, Float ppv, 
  Assurance iname) 

Inside AddProductsForSale method,I set values for my tableView like that:

 boolean find = false;
    Sale s = new Sale();
    s.setReference(ref);
    s.setDesignation(name);
    s.setDiscount(123);
    s.setPpv(ppv);
    s.setDiscount(0);
    s.setExpiration(exp);
     salelist.add(s);
        t2_ppv.setCellValueFactory(new PropertyValueFactory<Sale, Float>("ppv"));
        t2_discount.setCellValueFactory(new PropertyValueFactory<Sale, Integer>("discount"));
        t2_qty.setCellValueFactory(new PropertyValueFactory<Sale, Integer>("qty"));
        t2_reference.setCellValueFactory(new PropertyValueFactory<Sale, String>("reference"));
        t2_designation.setCellValueFactory(new PropertyValueFactory<Sale, String>("designation"));
        t2_expiration.setCellValueFactory(new PropertyValueFactory<Sale, String>("expiration"));
      
       
        t2_ppv.setCellValueFactory(new PropertyValueFactory<Sale, Float>("ppv"));
      
        t2.setItems(salelist);

But the problem is,the Column of String are empty but for other types as I provided real values,they are displayed.So,How Can I have rows without any values inside .Thank you so much.Excuse me for my English.

  • Ideally, rather than trying to set empty rows, you could just remove the placeholder completely, but I don't see an easy way to do that, Just setting the placeholder to null will show the default placeholder, not empty rows. Even if you subclassed the existing skin, the method you would want to replace with an empty implementation is final, see [TableViewSkinBase.updatePlaceholderRegionVisibility()](https://github.com/openjdk/jfx/blob/a9474055994d104288aff22fdb70f76ed8519627/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableViewSkinBase.java#L838). – jewelsea Dec 19 '21 at 04:47
  • 2
    Why would you want empty rows to be displayed in your `TableView`? I think that is the more important question. – Zephyr Dec 19 '21 at 06:23
  • @Zephyr had been wondering as well (after understanding what the OP wants).. but then there seem to be the occasional requirement for seemless visuals between empty and not empty tables. The bug database has an [open issue since 2013](https://bugs.openjdk.java.net/browse/JDK-8090949) (referenced in the duplicate) – kleopatra Dec 19 '21 at 12:42
  • @jewelsea duplicate magician :) – kleopatra Dec 19 '21 at 12:43

0 Answers0