javafx - JavaFX8 tree tabel view customize separate cells -
in tree-table-view there child items have in turn other child items. need customize, say, text of cells of pseudo-root items.
is there way assign css class/style items?
update:
ok, got working following cellfactory:
treetblcolumnname.setcellfactory(new callback<treetablecolumn<filemodel, string>, treetablecell<filemodel, string>>() { @override public treetablecell<filemodel, string> call(treetablecolumn<filemodel, string> param) { treetablecell<filemodel, string> cell = new treetablecell<filemodel, string>() { @override protected void updateitem(string t, boolean bln) { super.updateitem(t, bln); //to change body of generated methods, choose tools | templates. system.out.println(this.gettablecolumn().); label lbl = new label(t); lbl.setstyle("-fx-font-weight: bold; -fx-font-size: 14pt; -fx-text-fill: white;"); setgraphic(lbl); } }; return cell; } });
now, how can distinguish between classes? filemodel interface implemented several classes. in cellfactory need know type current cell->item in order apply different styling on it.
thanks.
you can use instanceof
:
filemodel filemodel = gettreetablerow().getitem(); if(filemodel instanceof exefilemodel){ //set style here } else if(filemodel instanceof txtfilemodel){ //use style here }
Comments
Post a Comment