Note that there are some explanatory texts on larger screens.

plurals
  1. POJavafx ListView selection bar text color when using CellFactory
    primarykey
    data
    text
    <p>Is there any way to change the selection bar text color in a list view? Preferably using CSS. In a TableView, you can use:</p> <pre><code>-fx-selection-bar-text: white; </code></pre> <p>But this does not work for a ListView.</p> <p><strong>UPDATE:</strong> The above case happens when using CellFactories to render the cells.</p> <pre><code>lvRooms.setCellFactory(new Callback&lt;ListView&lt;String&gt;, ListCell&lt;String&gt;&gt;() { @Override public ListCell&lt;String&gt; call(ListView&lt;String&gt; list) { return new RoomCell(); } }); </code></pre> <p>In the Cell Factory class, I'd gladly cover the case when the row is selected.</p> <p><strong>But:</strong> It is called just once at the beginning, not every time the selection bar is moved, and therefore the isSelected() method always renders false.</p> <p><strong>UPDATE 2</strong>: This is the RoomCell implementation:</p> <pre><code>class RoomCell extends ListCell&lt;String&gt; { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { Log.debug("RoomCell called, item: "+item); final Label lbl = new Label(item); // The room name will be displayed here lbl.setFont(Font.font("Segoe UI", FontWeight.BOLD, 18)); lbl.setStyle("-fx-text-fill: black"); //lbl.setTextFill(isSelected()?Color.WHITE: Color.BLACK); if (isSelected()) // This is always false :( lbl.setStyle("-fx-text-fill: yellow"); if (Rooms.getBoolean(item, "OwnerStatus")) { lbl.setEffect(new DropShadow(15, Color.BLUEVIOLET)); lbl.setGraphic(new ImageView( new Image(getClass().getResourceAsStream("images/universal.png")))); } else { lbl.setGraphic(new ImageView( new Image(getClass().getResourceAsStream("images/yin-yang.png")))); lbl.setEffect(new DropShadow(15, Color.WHITE)); } setGraphic(lbl); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload