Thanks in advance.
here is the code i've got thus far
Expand|Select|Wrap|Line Numbers
- package nestedsquare;
- import javax.swing.JFrame;
- public class Main {
- /** Creates a new instance of Main */
- public Main() {
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- JFrame application = new JFrame();
- DrawSquares panel = new DrawSquares();
- String myTitle = " NestedSquare ";
- application.setTitle(myTitle);
- application.add( panel ); // add the panel to the frame
- application.setSize( 263, 290 ); // set the desired size
- application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- application.setVisible(true);
- }
- }
Expand|Select|Wrap|Line Numbers
- package nestedsquare;
- import java.awt.Graphics;
- import javax.swing.JPanel;
- public class DrawSquares extends JPanel
- {
- public DrawSquares()
- {
- }
- // draws a cascade of shapes starting from the top left corner
- public void paintComponent( Graphics g )
- {
- super.paintComponent( g );
- for ( int i = 0; i < 256; i++ )
- {
- g.drawRect( 1 + i++, 1 + i++,
- 256 - i*2 , 256 - i*2 );
- }
- }
- } // end method