Struggling in creating chessboard!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Struggling in creating chessboard!!

  1. #1
    Join Date
    Aug 2005
    Posts
    1

    Arrow Struggling in creating chessboard!!

    Hey,I wanna create chessboard(only) without swings as i am a new programmer.Plz see this and say wats wrong with this code and necessary corrections


    import java.awt.*;
    import java.applet.*;

    public class board2 extends Applet
    {

    int i=0,j=0,a=0;


    public void init()
    {

    for(i=150;i<550;i+=50)//coordinates
    {
    for(j=50;j<=450;j+=50)//coordinates
    {

    a++;

    repaint();




    }

    }

    }


    public void paint(Graphics g)

    {




    if((a%2)==0)

    {


    g.setColor(Color.lightGray);

    g.fillRect(i,j,50,50);
    g.drawRect(i,j,50,50);
    }


    if((a%2)==1)
    {

    g.setColor(Color.black);

    g.fillRect(i,j,50,50);

    g.drawRect(i,j,50,50);

    }
    }
    }

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    First question: Do you get any errors when you compile the program?
    If so, copy and post them.
    If the program compiles OK, do you get any errors when you execute it?
    See above.
    Is the output what you want? If not, copy what it outputs and add comments describing what you want to change.

    Also you could add some comments to the code describing what each method is to do. Writing comments will help you think thru the logic while you write the program.

    Good luck.

Similar Threads

  1. Creating a session (newbie):
    By Jay in forum ASP.NET
    Replies: 2
    Last Post: 04-05-2002, 12:43 PM
  2. Creating a Recordset
    By Scott in forum VB Classic
    Replies: 2
    Last Post: 11-07-2001, 03:07 PM
  3. Defining & Creating views
    By neil in forum Database
    Replies: 2
    Last Post: 07-04-2001, 07:07 AM
  4. Creating Tables with ADOX
    By Lisa in forum VB Classic
    Replies: 4
    Last Post: 10-04-2000, 07:00 AM
  5. ADOX - creating tables
    By Lenny in forum VB Classic
    Replies: 2
    Last Post: 03-21-2000, 04:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center