Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaFX tableview colors
    primarykey
    data
    text
    <p>i need create JavaFx TableView with multicolor rows (color1 for low priority, color2 for medium priority etc.). I have created CellFactory</p> <pre><code>public class TaskCellFactory implements Callback&lt;TableColumn, TableCell&gt; { @Override public TableCell call(TableColumn p) { TableCell cell = new TableCell&lt;Task, Object&gt;() { @Override public void updateItem(Object item, boolean empty) { super.updateItem(item, empty); setText(empty ? null : getString()); setGraphic(null); TableRow currentRow = getTableRow(); Task currentTask = currentRow == null ? null : (Task)currentRow.getItem(); if(currentTask != null){ Priority priority = currentTask.getPriority(); clearPriorityStyle(); if(!isHover() &amp;&amp; !isSelected() &amp;&amp; !isFocused()){ setPriorityStyle(priority); } } } @Override public void updateSelected(boolean upd){ super.updateSelected(upd); System.out.println("is update"); } private void clearPriorityStyle(){ ObservableList&lt;String&gt; styleClasses = getStyleClass(); styleClasses.remove("priorityLow"); styleClasses.remove("priorityMedium"); styleClasses.remove("priorityHigh"); } private void setPriorityStyle(Priority priority){ switch(priority){ case LOW: getStyleClass().add("priorityLow"); break; case MEDIUM: getStyleClass().add("priorityMedium"); break; case HIGH: getStyleClass().add("priorityHigh"); break; } System.out.println(getStyleClass()); } private String getString() { return getItem() == null ? "" : getItem().toString(); } }; return cell; } } </code></pre> <p>and css</p> <pre><code>.priorityLow{ -fx-background-color: palegreen; } .priorityMedium{ -fx-background-color: skyblue;} .priorityHigh{ -fx-background-color: palevioletred;} </code></pre> <p>But i still need highlight selected rows. How can i do that?</p>
    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