K
K
krembrule20162018-10-22 21:53:58
Java
krembrule2016, 2018-10-22 21:53:58

How can I add an object of my own type to a node?

Good afternoon!
The essence of the question is as follows: I want to make an object that will contain several rectangles. Accordingly, this object must be added somehow like this

FlowPane rootNode = new FlowPane(10,10);
rootNode.getChildren().addAll(myLabel, nButton1, nButton2, *объект в котором группа ректанглов*);

In this example code, we are dealing with objects whose types are described in the Java standard libraries. And if I need to add an object of my own type, what should I do in this case? Those. I would like to add an object that will contain several objects of the rectangle.
The only option that comes to mind is that I will have a three-dimensional array with my rectangles and placement coordinates, and a loop in which, using the add () function, I will add my long-sufferers in turn. But something tells me that this is the clumsy collective-farm approach of worker-peasant ignorance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question