To be able to "erase" a shape, you will need to create a list of shapes for the paint method to draw.
The erase step will remove the shape from the list.
Type: Posts; User: Norm
To be able to "erase" a shape, you will need to create a list of shapes for the paint method to draw.
The erase step will remove the shape from the list.
Canvas is from the old awt classes. JPanel is part of Swing and has a lot more features that can be useful.
An inner class would be useful because it would allow the class to see the enclosing class's variables.
paint is not a good name for your class. paint is a method name for some classes and class...
Create a class that extends JPanel and in that class override the paintComponent() method.
Add an instance of that class to your GUI where you what to see it.
Your code is confused on who does the painting. For example JFrame does not have a paintComponent() method to override.
You should NOT override JFrame's paint method, but instead create a JPanel,...
You're not supposed to call the paint or paintComponent methods. You call the repaint() method and the JVM calls the paint method shortly after that and passes it a reference to a Graphics object....