Hello to all,
I have following simple Applet program.
import java.applet.*;
import java.awt.*;
public class myapp1 extends Applet
{
Label l1, l2, l3, l4;
TextField t1;
TextArea t2;
Checkbox c1,c2,c3,c4,c5,c6;
CheckboxGroup cg;
Button b;
public void init()
{
l1=new Label("Enter your name: ", Label.RIGHT);
t1=new TextField(20);
l4= new Label("Enter your gender: ");
cg=new CheckboxGroup();
c5=new Checkbox("Male",cg,true);
c6=new Checkbox("Female",cg,false);
l2=new Label ("About Workshop: ");
c1=new Checkbox("Timely Completion");
c2=new Checkbox("Excellent Resourse Persons", true);
c2.setEnabled(false);
c3=c1=new Checkbox("Good Food");
c1=new Checkbox("Excellent Hospitality");
l3=new Label("Any other comment:");
t2=new TextArea(10,20);
b=new Button("OK");
b.setForeground(Color.blue);
add(l1);
add(t1);
add(l4);
add(c5);
add(c6);
add(l2);
add(c1);
add(c2);
add(c3);
add(c4);
add(l3);
add(t2);
add(b);
}
}
This program shows blank Applet with Labels, Button and CheckBoxes.
It shows follo. exception on Command Prompt.
java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1086)
at java.awt.Container.add(Container.java:410)
at myapp1.init(myapp1.java:39)
at sun.applet.AppletPanel.run(AppletPanel.java:434)
at java.lang.Thread.run(Thread.java:722)
Please help me to display proper output.