hi all, I need to draw a series (10) concentric circles starting fromt he middle of the panel. This is what I have done, do you reckon it is ok?
//Ovals.java
import java.awt.Graphics;
import javax.swing.JPanel;
public class Ovals extends JPanel{
public void paintCmponent(Graphics g){
super.paintComponent(g);
//calculates the centre of the frame
int widthMiddle = ((g.getWidth()) / 2);
int heightMiddle = ((g.getHeight()) / 2);
//draw the rectangles
for(int = i; i < 10; i++){
g.drawOval(widthMiddle - (i * 10), heightMiddle - (i * 10), 1 + (i * 10), 1 + (i * 10));
}
}
}
and
//OvalsTest.java
//This program draws concentric circles starting fromt the middle of the frame
import javax.swing.JFrame;
public OvalsTest{
public void static main( String[], args){
Ovals ovalsPanel = new Ovals();
JFrame newFrame = new JFrame();
newFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
newFrame.add( ovalsPanel );
newFrame.setSize( 250, 250 );
newFrame,setVisible( true );
}
}
thanks