Applet to change text color
Hello guys, I'm sort of a beginner to java and they gave us this program in school which I can't seem to compile. It's basically an applet to change color of text as the user wishes. Here's the code:
Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AnimateColor extends Applet implements ActionListener
{
Button b;
Label l;
TextField tf;
String msg="Font animation";
public Animatecolor()
{
super();
}
public void destroy()
{
}
public void init()
{
l=new Label("Enter color");
tf=new TextField(15);
b=new Button("CHANGE");
add(l);
add(tf);
add(b);
setLayout(null);
l.setBounds(40,40,150,20);
tf.setBounds(200,40,200,40);
b.setBounds(100,80,100,40);
b.addActionListener(this);
}
public void start()
{
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
public void stop()
{
}
public void actionperformed(ActionEvent ae)
{
String st=ae.getActionCommand();
String s=tf.getText();
if(s.equalsIgnoreCase("red"))
setForeground(Color.red);
else
if(s.equalsIgnoreCase("yellow"))
setForeground(Color.yellow);
else
if(s.equalsIgnoreCase("blue"))
setForeground(Color.blue);
else
if(s.equalsIgnoreCase("black"))
setForeground(Color.black);
else
if(s.equalsIgnoreCase("cyan"))
setForeground(Color.cyan);
tf.setText("");
}
}
The error I am getting at compilation is
"AnimateColor.java:10: Invalid method declaration; return type required"
Any help would be appreciated!!