package Drawnings; import CollectionGenericObjects.AbstractCompany; import CollectionGenericObjects.ICollectionGenericObjects; import CollectionGenericObjects.MassiveGenericObjects; import javax.swing.*; import java.awt.*; public class CanvasFormDumpTruckCollection extends JComponent { public ICollectionGenericObjects collection = new MassiveGenericObjects(); public AbstractCompany company = null; public void SetCollectionToCanvas(AbstractCompany company) { this.company = company; } public CanvasFormDumpTruckCollection(){}; public void paintComponent(Graphics g) { super.paintComponents(g); if (company == null || company._collection == null) { return; } company.DrawBackgound(g); for (int i = 0; i < company._collection.getCount(); i++) { Graphics2D g2d = (Graphics2D) g; T obj = (T)company._collection.Get(i); if (obj instanceof DrawningTruck) { ((DrawningTruck) obj).DrawTransport(g2d); } } super.repaint(); } }