Hi, I got a question. I have a Resource class that extends java.util.ListResourceBundle, which holds several values. These are not only Strings but also doubles, for example. Now I want to access these values inside my FXML. It works very easy with String resources with the % sign, but did not work for me with any other type.
Here is some example code:
Resource class:
public class Resources extends java.util.ListResourceBundle {
private static final Object[][] OBJECTS = new Object[][]{
{"FOO", "foo"},
{"BAR", 123d}
}
@Override
protected Object[][] getContents() {
return OBJECTS;
}
}
Loading the FXML in Application class:
Resources resources = new Resources();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/foo.fxml"), resources);
Parent root = loader.load();
FXML:
<Label text="%FOO">
<Polygon>
<points>
<Double fx:value="0"/>
<Double fx:value="0"/>
<Double fx:value="%BAR"/>
<Double fx:value="0"/>
</points>
</Polygon>
The first line in FXML works perfectly fine, however the line with %BAR crashes with javafx.fxml.LoadException
I posted this question on SO two weeks ago but never got an answer. (java - JavaFX: Access in FXML to a non-String-Object from a ResourceBundle - Stack Overflow )
I hope you can help me.
Thanks a lot!