Two Errors in Java code Please help?
Hi could someone please assist me in correcting these two errors?
code: import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Label.*;
public class Freddie extends Applet implements ItemListener
{
//Construct Components
Label sandwichPromptLabel = new Label("sandwich");
Label sandwichInputField = new TextField("Input");
Label sizePromptLabel = new Label("size");
CheckboxGroup sandwichGroup = new CheckboxGroup();
Checkbox catsupBox = new Checkbox("catsup",false,sandwichGroup);
Checkbox mustardBox = new Checkbox("mustard",false,sandwichGroup);
Checkbox picklesBox = new Checkbox("pickles",false,sandwichGroup);
Checkbox sizeGroupBox = new Checkbox("sizeGroup",true,sandwichGroup);
Checkbox smallBox = new Checkbox("small",false,sandwichGroup);
Checkbox mediumBox = new Checkbox("medium",false,sandwichGroup);
Checkbox largeBox = new Checkbox("large",false,sandwichGroup);
public void init()
{
setBackground(red);
add(sizePromptLabel);
add(sandwichInputField);
add(sizePromptLabel);
add(catsupBox);
catsupBox.addItemListener(this);
add(mustardBox);
mustardBox.addItemListener(this);
add(picklesBox);
picklesBox.addItemListener(this);
add(sizeGroupBox);
sizeGroupBox.addItemListener(this);
add(smallBox);
smallBox.addItemListener(this);
add(mediumBox);
mediumBox.addItemListener(this);
add(largeBox);
largeBox.addItemListener(this);
}
public void itemStateChanged(ItemEvent choice)
{
}
}
Errors: C:\Course Technology\59850d\Chapter 04\Freddie.java:22: incompatible types
found : java.awt.TextField
required: java.awt.Label
Label sandwichInputField = new TextField("Input");
^
C:\Course Technology\59850d\Chapter 04\Freddie.java:36: cannot find symbol
symbol : variable red
location: class Freddie
setBackground(red);
^
2 errors
Thank You :-)