The Java code listed on this page ought to display this:

Instead, however, it displays this:

I'm using Java 2 version 1.4.1


PICTURE: redblue.PNG

PICTURE: yellow.PNG

FILE: StrangeApplet.java
import javax.swing.*;
import java.applet.*;

public class StrangeApplet extends JApplet {

   private RedBluePanel rbp;

   public StrangeApplet() {
      rbp = new RedBluePanel();
      getContentPane().add(rbp);
   }

}

FILE: RedBluePanel.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.net.*;

public class RedBluePanel extends JPanel {

   private Image redblue;
   private YellowPanel yp;

   public RedBluePanel() {

      yp = new YellowPanel();
      Toolkit kit = Toolkit.getDefaultToolkit();
      setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
      setBorder(new EmptyBorder(30,30,0,0));

      try {
         redblue = kit.getImage(new URL(Local.urlPrefix + "redblue.PNG"));
      } catch (java.net.MalformedURLException eek) {
         throw new RuntimeException();
      }

      MediaTracker mt = new MediaTracker(this);
      mt.addImage(redblue, 0);
      try {
         mt.waitForID(0);
      } catch (InterruptedException eek) {
         throw new RuntimeException();
      }

      add(yp);

   }

   public void paint (Graphics g) {
      g.drawImage(redblue, 0, 0, null);
      yp.repaint();
   }

}

FILE: YellowPanel.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.net.*;

public class YellowPanel extends JPanel {

   private Image yellow;

   public YellowPanel() {

      Toolkit kit = Toolkit.getDefaultToolkit();

      try {
         yellow = kit.getImage(new URL(Local.urlPrefix + "yellow.PNG"));
      } catch (java.net.MalformedURLException eek) {
         throw new RuntimeException();
      }

      MediaTracker mt = new MediaTracker(this);
      mt.addImage(yellow, 0);
      try {
         mt.waitForID(0);
      } catch (InterruptedException eek) {
         throw new RuntimeException();
      }

   }

   public void paint (Graphics g) {
      g.drawImage(yellow, 0, 0, null);
   }

}

FILE: Local.java
public abstract class Local {
   public static String urlPrefix = "http://web.netyp.com/member/dragon/java/strange/";
}

Here is the applet: