public void init() {
Label l;
l = new Label("Hello Container");
this.add(l);
}
The key thing to remember about adding components to the applet is the three steps:
You can often combine the three steps into one like this
this.add(new Label("Hello Container"));
The disadvantage to this shortcut is that you no longer have a variable which references the Label
. Thus you can't easily access the Label
later. However labels are fairly constant things, so you're unlikely to want to access it anyway.