title: adding css file to stylesheets in javafx
body: <p>Language: JavaFX</p>
  
  <p>IDE: Netbeans</p>
  
  <p>Problem: I'm trying to add a css file to the stylesheet, but the first line of the following code always generates a <code>NullPointerException</code>:</p>
  
  <pre><code>String css = this.getClass().getResource("double_slider.css").toExternalForm(); 
  scene.getStylesheets().add(css);
  </code></pre>
  
  <p>I've tried replacing "double_slider.css" with the full path. double_slider.css is currently located in the same package as the class that makes this call. I've also tried all of the variations found at <a href="http://introjava.wordpress.com/2012/03/21/linking-a-css-style-sheet-to-javafx-scene-graph/" rel="noreferrer">http://introjava.wordpress.com/2012/03/21/linking-a-css-style-sheet-to-javafx-scene-graph/</a>, with no success. Clean and build doesn't help either.</p>
  
  <p>If I place the css file in the build folder where the .class files are dumped, the NullPointerException goes away. But then the css file does not work properly because it references other files in my project.</p>