I am trying to draw on the glass pane part of a JFrame
with a marker using g.fillPolygon(xValues, yValues, numPoints)
after making the background of the JFrame
transparent.
I am using a method to find the location of the cursor and can get the right locations. To force the call of paintComponent(Graphics g)
, I am using myGlassPane.repaint()
but this deletes the previous part of the segment that I drew.
I am wondering if there is a way to retain what was previously drawn through the paintComponent(Graphics g)
method.
I am wondering if there is a way to retain what was previously drawn through the
paintComponent(Graphics g)
method.
Yes, add whatever you drew before either to a BufferedImage
or a List
which can allow you to create it...
For example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.