• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

graphic errors

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im getting mostly graphic errors for a animation applet in the book "The Black Art of Java Game Programming". Im wondering if anyone can see what might be causing it, I dont think its syntax. I'll post the code if need be.


[ September 26, 2005: Message edited by: Brad Cantrell ]
[ September 26, 2005: Message edited by: Brad Cantrell ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main problem is that your code appears to be missing import java.awt.*;

That's why it can't find the Graphics or Color classes.
 
Brad Cantrell
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc, but Im having the same problem with a simpler program out of the same book, and it has the import java.awt.*; I'll post the code for that as its only one file and the error message I get with it.

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

public class Mondrian2 extends Applet {
static final int NUM_RECTS = 9;

DancingRect r[];

public void init() {
System.out.println(">> init <<");
setBackground(Color.black);
initRectangles();
}
public void initRectangles() {
//allocate dancing rectangles
//now the data is encapsulated by the objects!
r = new DancingRect[NUM_RECTS];
r[0] = new DancingRect(0,0,90,90,Color.yellow);
r[1] = new DancingRect(250,0,40,190,Color.yellow);
r[2] = new DancingRect(200,55,60,135,Color.yellow);
r[3] = new DancingRect(80,200,220,90,Color.blue);
r[4] = new DancingRect(100,10,90,80,Color.blue);
r[5] = new DancingRect(80,100,110,90,Color.lightGray);
r[6] = new DancingRect(200,0,45,45,Color.red);
r[7] = new DancingRect(0,100,70,200,Color.red);
r[8] = new DancingRect(200,55,60,135,Color.magenta);

}
public void start() {
System.out.println(">> start <<");
}
public void paint(Graphics g) {
for (int i=0; i<NUM_RECTS; i++) {
r[i].paint(g);
}
}
public void stop() {
System.out.println(">> stop <<");
}

} [/CODE]
[ September 26, 2005: Message edited by: Brad Cantrell ]
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That compiles fine for me, once I add a dummy class that I don't have code for...
 
Brad Cantrell
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, thats weird, because I put your code into the DancingRect class and I still get 2 errors:
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like your DancingRect class needs import java.awt.*; too.
[ September 26, 2005: Message edited by: marc weber ]
 
Brad Cantrell
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Youre right, thanks Marc.
 
reply
    Bookmark Topic Watch Topic
  • New Topic