This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Canvas class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Canvas class" Watch "Canvas class" New topic
Author

Canvas class

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 815
How can I use the Canvas class within a loop to create a circle of different sizes and then store each Canvas object generated within a GridLayout. Can I use the same Canvas object within the loop and just assign to different rows and columns as I go or do I need to create an array, etc..,?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

What happened when you tried it out?


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 815
Wouter,
Found the problem. I was passing in an array and assigning it to a private variable in the class but since I wasn't making a copy of the array (circle info) it was making all the circles the same size as the last one done. I changed the code to copy the array passed in instead of a direct assignment to and it works fine now. Thanks for the response.

Rob
 
Consider Paul's rocket mass heater.
 
subject: Canvas class
 
Similar Threads
how to make Canvas transparent ?
Drawing
Midlet Colours? (On forms etc..)
MIDP Canvas problem!!!
Multiple Socket connection