title: ToggleButton to keep previous color after deselection
body: <p>I'm trying to make colored toggle buttons to remember their color before they were selected, for example, a black button is selected will be gray, and after it's deselected it will be back to black.</p>
  
  <p>When the buttons are created they are given these properties:</p>
  
  <pre><code>    cell.setStyle("-fx-border-color: black; -fx-background-color: gray; -fx-base: gray; -fx-border-width: 1");
      cell.setOnAction(event -&gt; setPerformAction(cell));
  </code></pre>
  
  <p>That's the event:</p>
  
  <pre><code>public void setPerformAction(ToggleButton cell) {
      if(cell.isSelected()) {
          cell.setStyle("-fx-border-color: red");
      }
      else{
          cell.setStyle("-fx-border-color: black");
      }
  }
  </code></pre>
  
  <p>The black and white were applied like this:</p>
  
  <pre><code>cell.setStyle("-fx-base: white; -fx-background-color: white; -fx-border-width: 1");
  </code></pre>
  
  <p>But as you see in the gif below, when the buttons are deselected, all of them return to a different color. How can they remember their previous color?</p>
  
  <p>BTW those buttons are generated dynamically on runtime so I can't see them in scene builder and they don't have css code.</p>
  
  <p><a href="https://i.stack.imgur.com/GtKaL.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/GtKaL.gif" alt="enter image description here"></a></p>