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

public class Mojo extends JApplet {
    Image img;

    public Mojo() {
	img = null;
    }

    public void init() {
	try {
	    URL u = new URL("http://www.lunabase.org/~faber/tmp/airted.xpm");
	    System.out.println(u != null ? u.toString() : "null");
	    img = getImage(u);
	    System.out.println(img != null ? img.toString() : "null");
	}
	catch (MalformedURLException e) {
	    System.err.println("Bad url: " + e.toString());
	}
    }


    /**
     * Simple command line invocation, for debugging.
     */
    static public void main(String argv[]) {
	JFrame f = new JFrame("Mojo");
	Mojo m = new Mojo();
	int x = 100, y=100;

	if ( argv.length > 0 ) x = Integer.parseInt(argv[0]);
	if ( argv.length > 1 ) y = Integer.parseInt(argv[1]);

	if ( x < 0 ) x = 100;
	if ( y < 0 ) y = 100;

	f.setVisible(true);
	// get the insets (f needs to be visible for that) and resize the frame
	// so that the dial has the requested area.
	Insets in = f.getInsets();
	f.setSize(x + in.left + in.right, y + in.top + in.bottom);
	f.setLocation(10,10);
	m.init();
	f.setContentPane(m);
	f.addWindowListener(new WindowAdapter() {
	    public void windowClosing(WindowEvent e) {
		System.exit(0);
	    }
	});
	f.validate();
	m.start();
    }
}
