This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates 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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 823
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: 823
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Canvas class