If it was a similar problem, either or both of the solutions offered in the
thread this was removed from should have sufficed.
When posting code, please
UseCodeTags <- link
Here i am able to draw rectangle but it is disappearing when i stop the mouse dragging only.
Well, that's what the code is written to do. Di you write that code or copy it from somewhere without understanding it?
As I am new to graphics, can you please give me the code clearly which is need to be added or modified.
No, this is a forum,
NotACodeMill <- link
What we
will do is help you to understand what the code does, and make the changes yourself. Start by adding the code tags, and trying to understand what the code does. Refer to the API for java.awt.Rectangle to see what result is specified when you call the method you used, and the documentation for MouseListener to correctly understand
when each method is called.