I want to use LineChartEx (an extended class) directly in place of LineChart within FXML.
I've extended LineChart to add some extra methods that I need from the forms controller, but this question is applicable to extending any JavaFX control/component.
The FXML for LineChart has components (xAxis,yAxis, etc) how do I replace instances of LineChart with my extended version, say LineChartEx.
The only way that I've got it to work is to create an FXML file:
<fx:root type="LineChart">
</fx:root>
and add a non-arg constructor to my LineChartEx that loads the FXML:
public LineChartEx() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("LineChartEx.fxml"));
}
This works, BUT the standard line chart constructor is:
public LineChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis) {
...
}
My extended LineChartEx doesn't read the parameters from the embedded FXML. All I want to do is use LineChartEx directly in place of LineChart.