In order for you to create a component, you must do the following:
Inherit your class from one of the components (in your case from LineChart)
In fxml add import with this class
In the description of the element itself in fxml, you must describe the starting parameters - these are the parameters that you pass to the constructor.
Example
public class MyLineChart<X, Y> extends LineChart<X, Y> { String field1; Intger field2; public class MyLineChart(String field1, Integer field2, Axis<X> xAxis, Axis<Y> yAxis) { super(xAsix, yAxis); this.field1 = field1; this.field2 = field2; }
fxml
<MyLineChart field1="SomeString" field2="100" xAsix="" yAxis=""/>
PS and generally create a class, do not include it in fxml, but simply manually add it to the panel (in the initialize
method, create a new instance of your class, and add it where you need it)
UPDATE
Then do so if fxml does not work
<BorderPane id="" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="232.0" prefWidth="289.0" xmlns:fx="http://javafx.com/fxml" fx:controller="charts2.Controller"> <top> <Pane id="pnHeader" prefHeight="67.0" prefWidth="790.0"> <children> <Label id="lblTitle" layoutX="14.0" layoutY="15.0" text="MyJavaFX"> <textFill> <Color blue="0.250" green="0.250" red="0.250" fx:id="x1" /> </textFill> </Label> </children> </Pane> </top> </BorderPane>
And in the class Controller.java write the following
package charts2; import javafx.fxml.FXML; public class Controller { private LineMarkerChart lmc; @Ovveride public void initialize(URL url, ResourceBundle resourceBundle) { this.lmc = new LineMarketChart("asd",100,new Axis(), new Axis()); } }