I have a custom class called ‘Language’, I want to define it in fxml like:
<Language fx:value="getBundle">
</Language>
Language extends Object directly and not any JavaFX component. Obviously it throws the below Exception:
Unable to coerce com.bl.commons.Language@69435 to class javafx.scene.Node
So how do I do it? What I want is that, most of my modal is in that class and I want to directly call methods of Language and set content in fxml itself. If this is not possible then any alternatives?
As far as I know your class has to extend
Nodein some way in order to be added to the list of children of other elements (which is what you are doing when you put it anywhere in FXML), because those children are stored asObservableList<Node>.Note that this doesn’t really mean you have to do anything special, just do:
If
Languagealready extends something else you will want to make that class extendNodeor rethink your class hierarchy.