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