import javax.swing.*; import java.awt.*; public class CanvasDumpTruck extends JComponent { public DrawningDumpTruck _drawningDumpTruck; public CanvasDumpTruck() {} public void paintComponent(Graphics g) { if (_drawningDumpTruck == null) { return; } super.paintComponents(g); Graphics2D g2d = (Graphics2D) g; _drawningDumpTruck.DrawTransport(g2d); super.repaint(); } }