File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Canvas class" Watch "Canvas class" New topic

Canvas class

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 832
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: 832
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.

I agree. Here's the link:
subject: Canvas class
It's not a secret anymore!