Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

class playBalloon must be declared abstract ???

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
What does that error mean??? (see title of post)

The bolded line is the line it's reffering to:



import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

public class playBalloon extends Applet implements ActionListener{

private Button btMake, btLeft, btRight, btUp, btDown, btGrow, btShrink, btPrev, btAR;
private Balloon newBalloon, wrkBalloon;
private Button newBut(String s) {Button bt = new Button(s); add(bt); bt.addActionListener(this); return bt;}

public void init()
{
btMake = newBut("Make");
btLeft = newBut("Left");
btRight = newBut("Right");
// btUp = newBut("Up");
// btDown = newBut("Down");
// btGrow = newBut("Grow");
// btShrink = newBut("Shrink");
btPrev = newBut("Prev");
btAR = newBut("All Right");
}

public void actionPreformed(ActionEvent event)
{
if (event.getSource() == btMake)
{Balloon prevBalloon = newBalloon; newBalloon = new Balloon(30,50,50,prevBalloon); wrkBalloon = newBalloon;}

if (wrkBalloon != null)
{
if (event.getSource() == btLeft) {wrkBalloon.moveH(-5);}
if (event.getSource() == btRight) {wrkBalloon.moveH(+5);}
if (event.getSource() == btUp) {wrkBalloon.moveV(-5);}
if (event.getSource() == btDown) {wrkBalloon.moveV(+5);}
if (event.getSource() == btGrow) {wrkBalloon.grow(+5);}
if (event.getSource() == btShrink) {wrkBalloon.grow(-5);}
if (event.getSource() == btPrev) {wrkBalloon = wrkBalloon.prev(); if (wrkBalloon == null) wrkBalloon = newBalloon;}
if (event.getSource() == btAR) {Balloon b = newBalloon; while (b != null) {b.moveH(3); b = b.prev();}}
}
repaint();
}

public void paint(Graphics g)
{if (newBalloon != null) newBalloon.display(g);}
}

class Balloon
{
private int diameter, xCoord, yCoord;
private Color color;
private Balloon pB;

public Balloon(int initialD, int initialX, int initialY, Balloon initialB)
{
diameter = initialD;
color = Color.black;
xCoord = initialX;
yCoord = initialY;
pB = initialB;
}

public void display(Graphics g)
{
g.setColor(color);
g.fillOval(xCoord, yCoord, diameter, diameter);
if (pB != null) pB.display(g);
}

public void moveH(int dX) {xCoord = xCoord + dX;}
public void moveV(int dY) {yCoord = yCoord + dY;}
public void grow(int dD) {diameter = diameter + dD;}
public Balloon prev() {return pB;}
}


I could really use your help on this one !!!
Thanx in advance,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
If you implement an interface you are required to provide implementation for all of the methods that the interface describes. If you don't, you must declare the class abstract (which means it can't be instantiated and all subclasses must implement the abstract methods).

In you case, this is because you didn't implement actionPerformed(). Well, you did but you misspelled it so it doesn't count. Fix that and you're golden.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top