Hey everyone, first post from me.
I'm currently doing a programming course and although so far I've been able to get my head around my assignments this one has me stumped. Here is the code which when run draws a circle at the top left of the frame.
The assignment is to use a loop that would redraw the circle multiple times, diagonally across the frame finishing at the bottom right corner.
I'm not looking for someone to simply solve it for me, but point me in the right direction as so far I just can't get my head around it.
Cheers in advance!
import javax.swing.*; import java.awt.*; import java.awt.geom.Ellipse2D; public class DrawShapes extends JFrame { public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; super.paint(g2); int w = getWidth(); int h = getHeight(); g.setColor(Color.GREEN); Ellipse2D.Double myEllipse; myEllipse = new Ellipse2D.Double(50, 50, 25, 25); g2.fill(myEllipse); } public static void main(String[] args) { DrawShapes p = new DrawShapes(); p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.setSize(500,500); p.setVisible(true); } }