title: JavaFX .setStyle(...) isn't not working when `-fx-background-image` changes
body: <blockquote>
    <p>What i want to achieve:</p>
  </blockquote>
  
  <p>I am using a <code>FileChooser</code> and the user selects an appropriate <code>.jpg</code> image file . Then i am copying that image , renaming it <code>background.jpg</code> to a known folder and trying to set it as the background image of the application using <code>.setStyle(...);</code> There is not problem of copying the image [ i am checking it]</p>
  
  <hr>
  
  <blockquote>
    <p>The Problem that occurs:</p>
  </blockquote>
  
  <p>I have a Stage with a <code>BorderPane</code> . The <code>BorderPane</code> has an background <code>Image</code> , i do that using </p>
  
  <pre><code> borderPane.setStyle("-fx-background-image:url('filepath')");
  </code></pre>
  
  <p><strong>!It works well the first time!</strong></p>
  
  <p>->Then i am deleting that file [<strong>background.jpg</strong>] and i am replacing it with another file named also [<strong>background.jpg</strong>] . The background image of the <code>BorderPane</code> isn't changing ....</p>
  
  <p>I have tried also resetting the same style using again :</p>
  
  <pre><code>  borderPane.setStyle("-fx-background-image:url('filepath')");
  </code></pre>
  
  <p>Finally when i am changing the filename , for example  to [<strong>background-12.jpg</strong>] and reseting the style using the above it changes the background image.</p>
  
  <hr>
  
  <p>Which exactly is the problem ? I mean i am sure that the background.jpg has been created , i am checking it and also when i am changing the name to something other again and again it works .</p>
  
  <p><strong>Is the Java CSS Parser lazy to parse the new style which is the same but has other <code>-fx-background-image</code> resource ?</strong> </p>
  
  <p>As for the File path i am sure it is well , i am using the code below :</p>
  
  <pre><code>//Maou is the File URL in appropriate format for CSS
  String maou = file.getAbsoluteFile().toURI().toString()
  
  //Here i add the appropriate file separator, if not JavaFX will report error
  maou = maou.replaceAll("\\Q\\\\E", "//"); 
  
  //Print maou
  System.out.println("Maou=\n" + maou);
  </code></pre>
  
  <hr>
  
  <hr>
  
  <blockquote>
    <p><strong>Solution :</strong></p>
  </blockquote>
  
  <p>I found as best solution using James_D answer , a little bit modified so it covers the whole window:</p>
  
  <pre><code>BackgroundImage bgImg = new BackgroundImage(image, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
          new BackgroundSize(window.getWidth(), window.getHeight(), true, true, true, true));
  </code></pre>