Hi forum and my warm wishes for a productive (and healthy) new year for you and your family!
I have one object that extends JPanel, overrides paintComponent() and initializes/starts other objects, each of them running a
thread that is responsible for some stuff, including painting itself on the panel.
One design that I tried but it seems a bit botched is the main object's Graphics2D reference being shared amongst everyone so that each object can use it to draw itself (but having multiple threads changing the Graphics2D reference attributes will be a problem).
My main glitch is that I cannot animate anything in the panel.
For example in TestPaintClass1:
Instead of having the drawString method draw the new number each second and having it displayed, I get nothing (because paintComponent() waits untill the loop finishes, that is in 1000 seconds so that it can display the final result). I tried repaint() but it didn't work. Searching in the corresponding APIs did not yeild much results either.
This is an just an example, but inside the paintComponent() there should be a call to a display method of a TestPaintClass2 object to paint/update itself.
So to conclude: one main object that inits a JPanel/JFrame and has a Graphics2D reference and a sort collection of other objects that are running a thread which among other things is responsible to paint itself in the main JPanel/JFrame constructed from the main object.
The botched design does not concern me for now. The problem is in the updating of the painting of each object.
Thanks for your time,
george.