-
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);
}
}
}
-
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
-
Replies: 2
Last Post: 04-05-2002, 12:43 PM
-
By Scott in forum VB Classic
Replies: 2
Last Post: 11-07-2001, 03:07 PM
-
By neil in forum Database
Replies: 2
Last Post: 07-04-2001, 07:07 AM
-
By Lisa in forum VB Classic
Replies: 4
Last Post: 10-04-2000, 07:00 AM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks