title: JavaFX TableView bold whole row iff `message.isUnread()==true`
body: <p>I am trying to replicate Gmail behavior in Javafx TableView. Row of new Unread message should be shown in bold. Here is what I was able to do so far:</p>
  
  <p><a href="https://i.stack.imgur.com/CzQXg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CzQXg.jpg" alt="enter image description here"></a></p>
  
  <p>I can change background of the whole row, and bold a cell, but can't bold the whole row.
  How to explain Javafx to do this?</p>
  
  <pre><code>for each Cell cell in tableview: 
      get Message m corresponding to row.
      String style = m.isUnread() ? "
      cell.setStyle("-fx-font-weight: 800" : "-fx-font-weight: 100")
  
  
  
  
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  
  public class Message {
      final static public ObservableList&lt;Message&gt; data = FXCollections.observableArrayList(
              new Message("Bob", "Where are you?", true, true),
              new Message("Elise", "Payment", false, false),
              new Message("Charlie", "Read this book: 'Clean code'", true, true),
              new Message("Oscar", "Golf class tonight", true, false),
              new Message("Sam", "How is your TableView progress?", false, true),
              new Message("Alice", "Latte", true, true)
      );
  
      final private String  name;
      final private String  title;
      private boolean isUnread;
      private boolean isArchived;
  
      public Message(String name, String title, boolean isUnread, boolean isArchived) {
          this.name = name; this.title = title; this.isUnread = isUnread;this.isArchived = isArchived;
      }
      public String  getName()    { return name;    }
      public String  getTitle()  { return title;  }
      public boolean getIsUnread() { return isUnread; }
      public boolean getisArchived() { return isArchived; }
  
  
      public void setIsUnread(boolean isUnread) { this.isUnread = isUnread;     }
   }
  </code></pre>
  
  <p>MyTable.java</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.scene.Node;
  import javafx.scene.Scene;
  import javafx.scene.control.TableCell;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableRow;
  import javafx.scene.control.TableView;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.stage.Stage;
  import javafx.util.Callback;
  
  
  public class MyTable extends Application {
      public static void main(String[] args) throws Exception { launch(args); }
      public void start(final Stage stage) throws Exception {
          stage.setTitle("Inbox");
  
          // create a table.
          TableView&lt;Message&gt; table = new TableView(Message.data);
          table.getColumns().addAll(makeStringColumn("Name", "name", 150), makeStringColumn("Title", "title", 300), makeBooleanColumn("New", "isUnread", 150));
          table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
          table.setPrefHeight(250);
  
          stage.setScene(new Scene(table));
          stage.getScene().getStylesheets().add(getClass().getResource("message.css").toExternalForm());
          stage.show();
  
          // highlight the table rows depending upon whether we expect to get paid.
          int i = 0;
          for (Node n: table.lookupAll("TableRow")) {
              if (n instanceof TableRow) {
                  TableRow row = (TableRow) n;
                  if (table.getItems().get(i).getIsUnread()) {
                      row.getStyleClass().add("isReadRow");
                  } else {
                      row.getStyleClass().add("isUnreadRow");
                  }
                  i++;
                  if (i == table.getItems().size())
                      break;
              }
          }
      }
  
      private TableColumn&lt;Message, String&gt; makeStringColumn(String columnName, String propertyName, int prefWidth) {
          TableColumn&lt;Message, String&gt; column = new TableColumn&lt;&gt;(columnName);
          column.setCellValueFactory(new PropertyValueFactory&lt;Message, String&gt;(propertyName));
          column.setCellFactory(new Callback&lt;TableColumn&lt;Message, String&gt;, TableCell&lt;Message, String&gt;&gt;() {
              @Override public TableCell&lt;Message, String&gt; call(TableColumn&lt;Message, String&gt; soCalledFriendStringTableColumn) {
                  return new TableCell&lt;Message, String&gt;() {
                      @Override public void updateItem(String item, boolean empty) {
                          super.updateItem(item, empty);
                          if (item != null) {
                              setText(item);
                          }
                      }
                  };
              }
          });
          column.setPrefWidth(prefWidth);
          column.setSortable(false);
          return column;
      }
  
      private TableColumn&lt;Message, Boolean&gt; makeBooleanColumn(String columnName, String propertyName, int prefWidth) {
          TableColumn&lt;Message, Boolean&gt; column = new TableColumn&lt;&gt;(columnName);
          column.setCellValueFactory(new PropertyValueFactory&lt;Message, Boolean&gt;(propertyName));
          column.setCellFactory(new Callback&lt;TableColumn&lt;Message, Boolean&gt;, TableCell&lt;Message, Boolean&gt;&gt;() {
              @Override public TableCell&lt;Message, Boolean&gt; call(TableColumn&lt;Message, Boolean&gt; soCalledFriendBooleanTableColumn) {
                  return new TableCell&lt;Message, Boolean&gt;() {
                      @Override public void updateItem(final Boolean item, final boolean empty) {
                          super.updateItem(item, empty);
                          if (item != null) {
                              setText(item.toString());
                              this.getStyleClass().add(item ? "isUnreadCell" : "isReadCell");
                          }
                      }
                  };
              }
          });
          column.setPrefWidth(prefWidth);
          column.setSortable(false);
          return column;
      }
  }
  </code></pre>
  
  <p>(Message.css)   </p>
  
  <pre><code>   .column-header-background         { -fx-background-color: azure;       }
     .isReadRow                       { -fx-background-color: palegreen;   }
     .isUnreadRow                       { -fx-background-color: yellow;       }
     .isReadCell                      { -fx-font-weight: 100 ; -fx-text-fill: darkgreen;}
     .isUnreadCell                     { -fx-font-weight: 800 ; -fx-text-fill: red;}
  </code></pre>