I need to create a highly customizable control that allows users to use an image as the background. In order to achieve this, I am trying to figure out how to set the CSS Style in code to specify the user's chosen image.
Here is my current attempt (which resulted in a warning about "unknown protocol: c" that I don't understand):
BG = //The CSS String
"-fx-background-position : 50% 50%;\n" +
"-fx-background-repeat : no-repeat;\n" +
"-fx-background-size : contain;\n" +
"-fx-background-image : url(\"" + GS.bgImage.getAbsolutePath() + "\");\n";
BG += "-fx-border-width : " + GS.borderWidth + ";\n" //For adding the Border
+ "-fx-border-color : " + GS.borderColor.toString();
this.setStyle(BG);
The GS
class I created provides the information for the control's appearance. The GS.bgImage
represents the desired background image for the control. Am I making a mistake by using .getAbsolutePath()
? Or could it be something else?