Ik heb het volgende probleem, wanneer ik onderstaand stukje code probeer te compilen, geeft de compiler een error in regel 35 "b.teken(g);". Can't resolve symbol (g), ik ben redelijk ten einde raad, welke tweaker kan mij helpen.
// oefenen met strings
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends Applet implements ActionListener
{
final int AANTAL_BALLEN = 3;
Button btKnop = new Button ("Nieuwe bal");
Bal b;
public void init ()
{
b = new Bal();
setLayout (null);
btKnop.setBounds(100,30,100,30);
btKnop.addActionListener(this);
add(btKnop);
}
public void paint (Graphics g)
{
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource() == btKnop)
b.teken(g);
}
}
class Bal
{
int links = (int)(300*Math.random()+1);
int boven = (int)(240*Math.random()+1);
int lengte = (int)(10*Math.random()+10);
int breedte = (int)(10*Math.random()+10);
void teken (Graphics g)
{
g.setColor (Color.green);
g.fillOval (this.links, this.boven, this.lengte, this.breedte);
}
private void setWaarden (int links, int boven, int lengte, int breedte)
{
this.links = links;
this.boven = boven;
this.lengte = lengte;
this.breedte= breedte;
}
}
// oefenen met strings
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends Applet implements ActionListener
{
final int AANTAL_BALLEN = 3;
Button btKnop = new Button ("Nieuwe bal");
Bal b;
public void init ()
{
b = new Bal();
setLayout (null);
btKnop.setBounds(100,30,100,30);
btKnop.addActionListener(this);
add(btKnop);
}
public void paint (Graphics g)
{
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource() == btKnop)
b.teken(g);
}
}
class Bal
{
int links = (int)(300*Math.random()+1);
int boven = (int)(240*Math.random()+1);
int lengte = (int)(10*Math.random()+10);
int breedte = (int)(10*Math.random()+10);
void teken (Graphics g)
{
g.setColor (Color.green);
g.fillOval (this.links, this.boven, this.lengte, this.breedte);
}
private void setWaarden (int links, int boven, int lengte, int breedte)
{
this.links = links;
this.boven = boven;
this.lengte = lengte;
this.breedte= breedte;
}
}