Overriding paintComponent
- Draw a car:
public class MyPanel extends JPanel
{
public void paintComponent(Graphics g)
{
Graphics2D g2 =
(Graphics2D)g;
car.draw(g2);
}
...
}
- Problem: Screen is corrupted when moving frame
- Remedy: call super.paintComponent(g)
previous |
start |
next .... [Slide 18] ....