Forums Register Login

Painting ArrayList objects to Panel

+Pie Number of slices to send: Send
I've created a Point class where a Point holds an x and y coordinate.
If I have a while loop that updates x and y and then adds them as a point to my PointArray ArrayList, what would be the best way to paint each point to a panel.
I also would like the lines between each Point to appear. So it would paint first point, then paint 2nd point, drawing a continuous line between each point.

Condensed version of code:



+Pie Number of slices to send: Send
Check out Graphics#drawLine()
Also don't forget to invoke super.paintComponent() inside your overridden paintComponent
+Pie Number of slices to send: Send
And check out concurrency in Swing. Right now you are either calling Thread.sleep on the EDT, causing it to block, or you're calling repaint on a thread other than the EDT. You should do neither.
Run away! Run away! Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1593 times.
Similar Threads
How do I make a point travel in straight line?
Graphs and identifying adjacent nodes
StackOverflowError when trying to use threads
BreakOut Java Bug
Phasor applet-some prbs already compiled code written here
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:20:57.