// Demonstrating Label class (from Deitel & Deitel) import java.awt.*; import java.applet.*; public class MyLabel extends Applet { private Label label1, label2; public void init() { // Call label constructor with no text label1 = new Label(); // Set the label's text label1.setText("Started with no text"); // Set label text with constructor label2 = new Label("This is read-only text"); // add labels to applet container add(label1); add(label2); } public void paint(Graphics g) { g.drawString("label1's text is: " + label1.getText(), 25, 40); g.drawString("label2's text is: " + label2.getText(), 25, 55); label2.setText("Modified text"); g.drawString("label2's text is: " + label2.getText(), 25, 70); } }