JFX component from other components
How can I have custom component designed in fxml but still usable like <TestComponent />
9 Replies
⌛
This post has been reserved for your question.
Hey @Koblížkáč! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Just create a class with the name TestComponemt, extend some existing javaFX control or even a Control class and you are ready to go.
yeah but how can i design its children in fxml?
thats my goal
i want to basically create anchor pane with toolbar n stuff
it would make it easier if i could od it in fxml
because ill reuse it
If you extend some container class like VBox you can simply put children there like you put into a VBox
i think u dont understand me, i want it to work like react components if you know, you have components with predefined children, which will be there whenever u use it. i could add them in ctor, but it would be better as fxml i think
I don't know react. Can you show an example of the final FXML file? Maybe we will find a solution...
well what i meant is that i want this fxml:
to represent my TestComponent
You can do the following:
Create a class "TestComponent" which will extend for example a StackPane. Then in the constructor you will load the fxml file you provided and set it as a child of your component. Then you just have to somehow propagate the controller of the loaded view.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.