import javax.swing.*; import java.awt.*; public class LifeCycle extends JApplet { JLabel l1, l4; MyLabel l2, l3; public void init() { getContentPane().setBackground(Color.PINK); // getContentPane().setOpaque(true); DID NOT WORK! System.out.println("init()"); System.out.println(this); getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); l1 = new JLabel("Greg", JLabel.CENTER); l1.setBackground(Color.GREEN); l1.setOpaque(true); // The "getContentPane()" isn't necessary with the next statement add(l1); l2 = new MyLabel(); // By default, you can change the following statement to "this.add(l2);" add(l2); l3 = new MyLabel("Something"); add(l3); l4 = new JLabel("HTML
TEST", JLabel.CENTER); add(l4); } public void start() { System.out.println("start()"); } public void stop() { System.out.println("stop()"); } public void destroy() { System.out.println("destroy()"); } public void paint(Graphics g) { super.paint(g); g.drawString("Hello", 100, 100); System.out.println("paint()"); g.setColor(Color.MAGENTA); g.fillRect(150, 150, 75, 100); } }