Arraylists

ladynred

Member
Joined
Mar 20, 2006
Messages
5
Programming Experience
Beginner
Can someone explain to me how you get an arraylist to work in a drawing program? I have tried using some the examples I found online, but so far nothing works right. I have to set it up to be able for the user to choose a line, a rectangle, or freehand drawing. I don't really understand how arraylists work in this case.

Thanks for any help you can give.
Johnnie
 
You're going to have to give a bit more detail. It's not clear exactly what you want to use the ArrayList for. At a guess I would say that you should define a class or structure for each of the shapes that you're going to want to draw. Each time you create an object to draw you would place an instance of one of these types in an ArrayList. Then in your Paint event handler you just loop through the items in the ArrayList and draw them. To delete a drawn object you just remove the correpsonding object from the ArrayList and Refresh the form. Is that the sort of thing you mean?
 
Re:arraylists

I don't really understand it myself, but I am supposed to use an arraylist to store each line to draw. I'm using a Color Dialog Box for them to choose the color and a combo box to choose the width of the line and a combo box to choose the tool--line, rectangle, pencil.
Some examples I've seen use properties to set up the widths and colors. I haven't been able to get anything to work using arraylists.

Thanks,
Johnnie
 
Back
Top