I need to create a rectangle object and then paint it to the applet using paint(). I tried
Rectangle r = new Rectangle(arg,arg1,arg2,arg3);
Then tried to paint it to the applet using
g.draw(r);
It didn't work. Is there a way to do this in java? I have scoured google to within an inch of its life for an answer, but I haven't been able to find an answer. Please help!
Note:
drawRect
andfillRect
are different.Draws the outline of the specified rectangle:
Fills the specified rectangle. The rectangle is filled using the graphics context's current color:
You may try like this:
where x is x co-ordinate y is y cordinate color=the color you want to use eg Color.blue
if you want to use rectangle object you could do it like this:
Try this:
[edit]