css - JavaFX TableView change selected cell colour -
i have javafx tableview , listview , both use custom cell factories. in particular have overridden updateitem method in order bind particular css class based on cell value.
this part of css file:
.tissuecell { -fx-text-fill: #f5ad11; } .tissuecell:selected { -fx-background-color: #f5ad11; -fx-text-fill: white; } .significantdatacell { -fx-background-color: yellow; -fx-text-fill: black; } .significantdatacell:selected { -fx-background-color: white; -fx-text-fill: black; }
for listview work flawlessly: text displayed proper colour , when cell selected text becomes white , background filled proper colour.
i experiencing problems tableview instead. when unselected text in cell displayed chosen colour, when cell selected background filled default javafx colour selected table cells background , text colour remains #f5ad11 (it not become white).
the same happens tablecells use .significantdatacell class. cells displayed yellow background , black text, when selected nothing changes, not event background time.
any ideas? did lot of research couldn't find working solution.
by default, tableview
s not allow selection of individual cells, allow selection of rows. selector .table-cell:selected
never matches cell in default selection mode. in case, need
.table-row-cell:selected .table-cell { /* style definitions */ }
or in scenario
.table-row-cell:selected .tissue-cell { -fx-background-color: #f5ad11; -fx-text-fill: white; }
etc.
if allow table use cell selection, calling
mytableview.setcellselectionenabled(true);
then individual cells become selected on mouse click (etc), , original css work.
Comments
Post a Comment