-
Java graphics
I have created a chess board and menus on top. When I click on one of the menu items it erases part of the board, and when I minimize the window the board disappears. I thought that repaint() function would work but it doesn't. Anyone knows how to solve this problem?
Thank you.
-
Java Graphics
This is the code:
public void paint(Graphics g)
{
super.paint(g);
int l = 1;
l++;
System.out.println("This is a test " + l);
l++;
//Draw 64 squares with filled brown and white colors
for(int i=1; i<=64; i++)
{
if((i>=1 && i<=8)||(i>=17 && i<=24) || (i>=33 && i<=40)||(i>=49 && i<=56))
{
//Ranks 2,4,6,8.
if(i%2 ==0)
g.setColor(new Color(150,0,0));
else
g.setColor(Color.white);
}
else
//Ranks 1,3,5,7.
if(i%2==0)
g.setColor(Color.white);
else
g.setColor(new Color(150,0,0));
if(i%8!=0)
{
g.fillRect(x,y,SQRSWIDTH,SQRSHEIGHT);
x = x+50;
}
else
{
g.fillRect(x,y,SQRSWIDTH,SQRSHEIGHT);
x = 50;
y = y+50;
}
}
//draw the letters and numbers
g.setFont(new Font("Arial",Font.PLAIN,16));
g.setColor(Color.blue);
//Create for loop to draw the letters and numbers
for(int i=8; i>=1; i--)
{
g.drawString(Integer.toString(i),30,yloc);
yloc+= 50;
g.drawString(""+((char)ascii),xloc,490);
xloc+=50;
ascii++;
int k=1;
System.out.println("draw numbers " + ++k);
}//end of for loop
System.out.println("end of paint method ");
}//end of paint method
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