Results 1 to 4 of 4
Thread: chess code in applet
- 04-21-2012, 12:29 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
chess code in applet
/* <Applet code="MyApplet8" width="480" height="480">
</Applet>
*/
Java Code:import java.applet.*; import java.awt.*; public class MyApplet8 extends Applet { public void paint(Graphics g) { int w=getWidth(); int h=getHeight(); int y=0; for(int j=1;j<=4;j++) { for(int i=0;i<=w;i=i+w/8) { g.setColor(Color.BLACK); g.fillRect(i,y,w/8,h/8); i=i+w/8; g.setColor(Color.WHITE); g.fillRect(i,y,w/8,h/8); } y=y+h/8; for( int i=0;i<=w;i=i+w/8) { g.setColor(Color.WHITE); g.fillRect(i,y,w/8,h/8); i=i+w/8; g.setColor(Color.BLACK); g.fillRect(i,y,w/8,h/8); } y=y+h/8; } } }Last edited by Norm; 04-21-2012 at 12:39 PM. Reason: added code tags // Moved to applet area
- 04-21-2012, 12:40 PM #2
Re: chess code in applet
Please explain what the problem is. Does it compile and excute without errors? What happens when you load it into appletviewer or a browser?
If you don't understand my response, don't ignore it, ask a question.
- 04-26-2012, 01:07 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: chess code in applet
this code will create chess layout of 8x8 in applet u can also use this to create same layout in frame by importing frame there is no error in this code, it is for our friends who wants to create chess layout.
- 04-26-2012, 03:01 PM #4
Re: chess code in applet
This is a forum, not a blog. As such, this thread is off topic and will be closed now and removed later.
For those who read it before it vanishes, that badly indented code is poor on several accounts, not the least of which is that it extends the outdated AWT Applet and not the Swing JApplet which has been around for more than 10 years. The code also neglects the truncating effect of integer division, and uses two loops where one nested loop would suffice.
db
THREAD CLOSEDWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
chess game! plz help!
By mofaghih in forum AWT / SwingReplies: 2Last Post: 07-11-2011, 07:46 AM -
Help with Chess GUI
By Lord Voldemort in forum AWT / SwingReplies: 9Last Post: 01-24-2011, 05:38 PM -
Seeing Code in applet
By ravul1 in forum Java AppletsReplies: 1Last Post: 12-22-2010, 01:39 PM -
chess game
By michail in forum New To JavaReplies: 13Last Post: 01-12-2010, 07:24 AM


LinkBack URL
About LinkBacks

Bookmarks