color row tableview not change javafx -


i have tableview text message change color in term of type message. have following code :

tableviewerreur.setrowfactory(param -> new tablerow<boerreur>() {         @override         protected void updateitem(boerreur paramt, boolean empty) {             super.updateitem(paramt, empty);             if (!isempty() && paramt != null) {                 switch (paramt.getniveauerreur()) {                 case 0:                     setid(constantsui.css_erreur_info);                     break;                 case 1:                     setid(constantsui.css_erreur);                     break;                 default:                     break;                 }                 tableviewerreur.refresh();             }         }     }); 

and have following code have wrap text in cell :

tablecolumnerreur.setcellfactory(new callback<tablecolumn<boerreur, string>, tablecell<boerreur, string>>() {         @override         public tablecell<boerreur, string> call(tablecolumn<boerreur, string> arg0) {             return new tablecell<boerreur, string>() {                 private text text;                  @override                 public void updateitem(string item, boolean empty) {                     super.updateitem(item, empty);                     if (!isempty()) {                         text = new text(item.tostring());                         text.setwrappingwidth(tablecolumnerreur.getwidth());                         this.setwraptext(true);                          setgraphic(text);                      }                 }             };         }     }); 

the problem second code remove cell's color. , need make :

switch (paramt.getniveauerreur()) 

in rowfactory determinate row's color.

help please,

thanks.

if want make different colors in odd , rows need use code in .css file.

 .table-row-cell:odd{     //add color here }  .table-row-cell:even{     //add color here } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -