Click to See Complete Forum and Search --> : Applet that uses graphics methods and takes variable arguments.


batgirlkate
July 30th, 2003, 06:41 PM
If you have a public void init method, prompts the user for four integers and stores them in string type variables, then your next method is paint (applet ) and you want to use those four coordinates to drawRect, how can you pass the four user input values (stored in int variables) to drawrect method of the paint class/method?

ArchAngel
July 31st, 2003, 04:22 AM
I would write it so that my paint() method draws anything which is in a Vector instance variable e.g. toDraw.

Then when you've got the co-ordinates, use those numbers to create yourself an object e.g. Rectangle. Then add the object to the Vector.

There's probably a nicer way, but I don't think that's too bad...