javafx - JavaFX8 tree table view custom root row -
in tree-table-view have root item contains child items(i have mistakenly called them root items) in turn have child items. need customize mistakenly called root items rows text appearance. there such selector or how else done?
thanks.
this set pseudo-class on row containing root:
final pseudoclass firstrowclass = pseudoclass.getpseudoclass("first-row"); treetableview.setrowfactory(treetable -> { treetablerow<...> row = new treetablerow<>(); row.treeitemproperty().addlistener((ov, oldtreeitem, newtreeitem) -> row.pseudoclassstatechanged(firstrowclass, newtreeitem == treetable.getroot())); return row ; });
now can select row in css with
.tree-table-row-cell:first-row { ... }
complete example here
it sounds want style immediate child nodes of root node. in case, do
row.treeitemproperty().addlistener((ov, oldtreeitem, newtreeitem) -> row.pseudoclassstatechanged(firstrowclass, newtreeitem != null && newtreeitem.getparent() == treetable.getroot()));
instead of condition in code above. obviously, can use other criteria need them (e.g. ! newtreeitem.isleaf()
).
note default style sheet rules tree-table-row
little strange: -fx-background-color
set row, -fx-text-fill
set both row , cells inside it. if want change background color, need
-tree-table-row-cell:first-row { -fx-background-color: antiquewhite ; }
but if want change text color, need change on cells:
-tree-table-row-cell:first-row .tree-table-cell { -fx-text-fill: red ; }
Comments
Post a Comment