javafx: change style dynamically on pane
<p>I am trying to change the style of a pane when my mouse goes over it and change it back to normal when my mouse is outside the pane. </p>

<p>I can do something like that</p>

<pre><code>pane.setStyle("");
</code></pre>

<p>However I want my css code to be in a css stylesheet and I was wondering if it's possible to create something like togglebutton </p>

<pre><code>.togglebutton{
     -fx-background-color:red;
}

.togglebutton:selected{
     -fx-background-color:green;
}
</code></pre>

<p>Thus, each time I select my togglebutton, the style change automatically. </p>

<p>The question is : is it possible to create a parameter to act like the togglebutton. Something like:</p>

<p>css stylesheet</p>

<pre><code>.mypane{
     //do something
}

.mypane:selected{
     // do something else
}
</code></pre>

<p>java code</p>

<pre><code>public void mousedragAction(MouseEvent event){
     mypane.isSelected(true);
}

public void mouseexit(MouseEvent event){
     mypane.isSelected(false);
}
</code></pre>

<p>Thank you very much for any help, or any other solutions. </p>