-2

I have define the JPanel named drawPanel, and a button named Jbutton1 with an ActionListener. I want to continue draw something on the drawPanel after clicked the Jbutton1. And I do not want to clear the drawPanel first and draw more things, I just want to continue draw on the drawPanel and show it in a JFrame.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • What does the button have to do with `repaint()`? For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example) or [SSCCE](http://www.sscce.org/) (Short, Self Contained, Correct Example). – Andrew Thompson Apr 26 '15 at 09:06

1 Answers1

1

Check out Custom Painting Approaches for the two common ways to do this:

  1. Keep a List of Objects that you want to paint and then iterated through the list every time.
  2. Paint to a BufferedImage and then just paint the BufferedImage.
camickr
  • 321,443
  • 19
  • 166
  • 288