/*PROG 16.12 DEMO OF LABEL CLASS, WORKING WITH MULTIPLE LABELS */
import java.applet.*;
import java.awt.*;
/*
<applet code = "label2" width = 200 height = 75>
</applet>
*/
public class label2 extends Applet
{
Label L[];
public void init()
{
L = new Label[3];
for (int i = 0; i < L.length; i++)
{
L[i] = new Label("Label " + (i + 1));
L[i].setBackground(Color.cyan);
L[i].setForeground(Color.red);
add(L[i]);
}
L[0].setAlignment(Label.CENTER);
L[1].setAlignment(Label.LEFT);
L[2].setAlignment(Label.RIGHT);
}
}
Explanation:This program is simple ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.