java - Is there a Selektor for JavaFx based on text or rowNum? -
i want style javafx list cells based on text value. can style even/odd (s. below)
.list-cell:odd { -fx-font-size: 20;
}
is there possibility based on text, like
`.list-cell[text*='containedtext''] { -fx-font-size: 20; }
if not possible, there :nth-child() (this not working). know childs have selected, create css on fly. `
my final goal style autocomplete based on attributes of each entry.
regards andreas
i found solution styling autocomplete cells based on included text. it's not elegant. copied following classes:
autocompletepopup
autocompletepopupskin
autocompletion.css
autocompletionbinding
autocompletiontextfieldbinding
in autocompletepopup overwrote 1 method add cellfactory:
protected skin<?> createdefaultskin() { autocompletepopupskin = new autocompletepopupskin(this); final listview<t> listview = (listview) autocompletepopupskin.getnode(); listview.setcellfactory(l -> new textfieldlistcell<t>() { @override public void updateitem(t item, boolean empty) { super.updateitem(item, empty); this.getstyleclass().remove("bold"); if(!empty && item.tostring().contains("(h)")) { this.getstyleclass().add("bold"); } } }); return autocompletepopupskin; }
in css added class desired styling;
.bold { -fx-font: normal bold 12 serif;}
thx james_d gave me hint cellfactory!
Comments
Post a Comment