Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Color2.java:89: missing method body, or declare abstract

843810Dec 10 2002 — edited Dec 10 2002
I am creating a color chooser applet but I keep receiving this error please help me to resolve this as my heads wrecked.
Here is my code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Color2 extends Applet implements AdjustmentListener, ActionListener
{
Scrollbar redbar, grebar, blubar;
TextField rfield, gfield, bfield;
myColorSquare cSquare = new myColorSquare();

public void init()
{
cSquare.setSize(100,100);
this.add(cSquare);

Panel n= new Panel(new GridLayout(3,3));
n.add(new Label("Red (0-255)"));
this.redbar = new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
this.redbar.addAdjustmentListener(this);
n.add(redbar);
this.rfield = new TextField("0",5);
this.rfield.addActionListener(this);
n.add(rfield);

n.add(new Label("Green(0-255)"));
this.grebar = new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
this.grebar.addAdjustmentListener(this);
n.add(grebar);
this.gfield = new TextField("0",5);
this.gfield.addActionListener(this);
n.add(gfield);

n.add(new Label("Blue(0-255)"));
this.blubar = new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
this.blubar.addAdjustmentListener(this);
n.add(blubar);
this.bfield = new TextField("0",5);
this.bfield.addActionListener(this);
n.add(bfield);


this.add(n);
}

private void updateColor()
{
int red = this.redbar.getValue();
int green = this.grebar.getValue();
int blue = this.blubar.getValue();
this.rfield.setText(""+red);
this.gfield.setText(""+green);
this.bfield.setText(""+blue);
Color aColor = new Color(red,green,blue);
this.cSquare.updateColor(aColor);
}

public void adjustmentValueChanger(AdjustmentEvent e)
{
this.updateColor();
}

public void ActionPerformed(ActionEvent e)
{
if (e.getSource().equals(this.rfield))
{
int red = new Integer(this.rfield.getText()).intValue();
this.redbar.setValue(red);
}
if(e.getSource().equals(this.rfield))
{
int blue = new Integer(this.bfield.getText()).intValue();
this.blubar.setValue(blue);
}
if (e.getSource().equals(this.bfield))
{
int green = new Integer(this.gfield.getText()).intValue();
this.grebar.setValue(green);

}
this.updateColor();
}
}
class myColorSquare extends Canvas
{
Color c = Color.black;

public void paint(Graphics g);
{
g.setColor(this.c);
g.fillRect(0,0,this.getSize().width, this.getSize().height);
}


public void updateColor(Color v)
{
this.c = v;
this.repaint();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2003
Added on Dec 10 2002
1 comment
305 views