My panel's paintcomponent method draws a line based on the initial click and the current position as the mouse is dragged. Releasing the mouse leaves one line from the mouse press location to the mouse released location. The problem is. on the next click/drag, the old line disappears when the paint method is called again. Is there a way to save the old lines other than keeping them in a list and constantly redrawing them in the paintcomponent paint?
Srin
0
Newbie Poster
Recommended Answers
Jump to PostAre you calling repaint() after every action?
Not if you call repaint() all the time.
Jump to PostThe problem is. on the next click/drag, the old line disappears when the paint method is called again
You need to save old lines in a list that the paint method can access and use to draw the old lines as well as the current line.
There is no …
Jump to PostCreate a new class for a line. It would contain the x,y of the end points, the color and the width and any other property you want for the line. It would have a drawMe method that takes a Graphics object and does the drawing.
Objects of this class could …
All 12 Replies
hfx642
NormR1
563
Posting Sage
Team Colleague
Srin
0
Newbie Poster
sirlink99
56
Practically a Master Poster
Srin
0
Newbie Poster
efxee
0
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
Srin
0
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
efxee
0
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
Srin
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.