r/JavaFX • u/No-Specialist9049 • Oct 22 '24
Help Custom component in JavaFX(Best practice)
Hello, everyone. A question arose regarding the best practice of creating custom components in JavaFX. For example, we need to draw an atom. An atom contains a nucleus and electrons. What would be the best structure to draw from?
For example:
class Atom extend Pane {
Nuclear nuclear;
List<Electron> electrons;
}
class Nuclear extend Circle {}
class Electron extend Circle {}
Would it be best practice for the aggregator component to inherit from the container (in this case JavaFX Pane)? Is it possible to wrap the nucleus and electron in a container(Nuclear extend Pane) better?
I would be grateful for any tips
View all comments
Show parent comment
1
u/No-Specialist9049 Oct 22 '24
Considering the example of the atom. Is it better to wrap each circle in some container(Pane). Is it better to simplify the approach and use the Circles themselves? Or to expand the circle class? The main task is the convenience of maintaining the code in the future. And of course, so that it is not detrimental to productivity