Other languages >> Is there anything wrong with this?
Posted by Jason on 12:58:00 08-24-2002
I don't get it. Every time I try to compile this code, it won't work, as in it won't compile. Here's the code:

Code:
import java.applet.*;
import java.awt.*;


public class Scribble extends Applet {
private int last_x = 0;
private int last_y = 0;
private Color current_color = Color.black;
private Button clear_button;
private Choice color_choices;


public void init() {
this.setBackround(Color.white);


clear_button = new Button("Clear");
clear_button.setForeground(Color.black);
clear_button.setBackround(Color.lightGray);
this.add(clear_button);


color_choices = new Choice();
color_choices.addItem("black");
color_choices.addItem("red");
color_choices.addItem("yellow");
color_choices.addItem("green");
color_choices.setBackround(Color.lightGray);
this.add(new Label("Color: "));
this.add(color_choices);
}

public boolean mouseDown(Event e, int x, int y)
{
last_x = x; last_y = y;
return true;
}

public boolean mouseDrag(Event e, int x, int y)
{
Graphics g = this.getGraphics();
g.setColor(current_color);
g.drawLine(last_x, last_y, x, y);
last_x = x;
last_y = y;
return true;
}

public boolean action(Event event, Object arg) {
if (event.target == clear_button) {
Graphics g = this.getGraphics();
Rectangle r = this.bounds();
g.setColor(this.getBackround());
g.fillRect(r.x, r.y, r.width, r.height);
return true;
}
else if (event.target == color_choices) {
if (arg.equals("black")) current_color = Color.black;
else if (arg.equals("red")) current_color = Color.red;
else if (arg.equals("yellow")) current_color = Color.yellow;
else if (arg.equals("green")) current_color = Color.green;
return true;
}
else return super.action(event, arg);
}
}


Is there anything wrong with that? [addsig]
Posted by Peter on 17:16:00 08-24-2002
What error message do you get?
Posted by KaGez on 18:07:00 08-24-2002
compiler errors are the most useful informations you can give to other hackers for debugging
[addsig]
Posted by seunosewa on 20:59:00 09-03-2002
I would like to see the compilers' complaints, too...
Posted by KaGez on 23:41:00 09-03-2002
jason:
so, what does the compiler say now?
[addsig]
Posted by MoX on 18:57:00 09-04-2002
Heh, I guess we will wonder about that for the rest of our lives...

Please, jason, release us! [addsig]
Posted by sacah on 20:49:00 09-04-2002
My java wont compile it either, im not to sure whats wrong, mabye if i actually install it it might work, i shall try that.
(-:
Posted by KaGez on 20:52:00 09-04-2002
sacah:
didn't you have a java compiler?
[addsig]
Posted by sacah on 21:53:00 09-04-2002
Yes, i have a java compiler, but i dont have the lib files, so the imports dont work, so i just installed it, and tried to compile, its a simple problem, it always failes on the setBackground command, check the spelling, in the code you pasted, its typed 'setBackround' you are missin the 'g' after i added the g to spell it correctly, it worked fine.
Posted by KaGez on 22:07:00 09-04-2002
hehe, that's probably why he didn't give us the compiler output!
[addsig]
Posted by MoX on 22:45:00 09-04-2002
Nice programming problem then. Had several of these in my career [addsig]
Posted by KaGez on 22:54:00 09-04-2002
oh, not only you!
I just had one of those yesterday... I sat there for about 1 1/2 hours and debugged a PHP script, and the problem was only 1 typo in the end
[addsig]
Posted by seunosewa on 03:15:00 09-07-2002
Seems like sacah is the only one who actually tried to compile the program ...
Posted by sacah on 11:32:00 09-07-2002
I am probly the only one who programs in java here, none of the others would have java compiler or know how to use it, but from the errors reported they could have figure this problem out.
(-:
Posted by KaGez on 22:20:00 09-07-2002
I don't even own a java compiler
[addsig]
Posted by Cajun Fox on 02:45:00 01-09-2003
Hey!!Look!You're 10 years old and I'm 12,but you can desighn sites under JAVA and I can't! Stay cool!