The problem is that I have an ArrayList which stores objects that contain a Shape (actually a Composite shape like a Car) and (x,y) coordinates. Suppose I'm supposed to retrieve each object and the coordinates for drawing. My question is, how do I draw an Shape on the screen at position (x,y)? I looked in the API but didn't find any set() or overloaded draw() methods.

You will need to take a look at the java.awt.Graphics and java.awt.Graphics2D classes. They provide methods to draw shapes to what is called a graphics context (eg screen, image, printer etc). So if you want to draw a shape to the screen in say a javax.swing gui, you override the paint method in an extension of JPanel (or a similar JComponent) and call Graphics.draw(Shape).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.