
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import java.io.*;
import java.net.*;

public class DBJettApplet extends Applet implements ActionListener {
    Frame f;
    int newWinX, newWinY;

    Font btnFont;
    Font lblFont;

    int sizes[] = { 512, 640, 800, 1024 };
    String sizeNames[] = { "Small", "Medium", "Large", "Huge" };

    public void init() {
		btnFont = new Font("SansSerif", Font.BOLD, 14);
		lblFont = new Font("SansSerif", Font.ITALIC, 10);

		newWinX = 14;
		newWinY = 14;

		setLayout(new GridLayout(0,1,2,2));
		setBackground(Color.white);

		Panel p1;
		Button btn;
		Label lbl;

		for(int i = 0; i < sizes.length; i++) {
			p1 = new Panel();
			p1.setLayout(new FlowLayout(FlowLayout.LEFT));

			btn = new Button(sizeNames[i]);
			btn.setFont(btnFont);
			btn.setActionCommand(sizeNames[i]);
			btn.addActionListener(this);

			p1.add(btn);

			lbl = new Label(" (" + sizes[i] + "x" + sizes[i] + ")", Label.RIGHT);
			lbl.setFont(lblFont);

			p1.add(lbl);
			add(p1);
		}
    }

    public void actionPerformed(ActionEvent e) {
		String nam = e.getActionCommand();
		int i;

		for(i = 0; i < sizes.length; i++) {
			if (sizeNames[i].equals(nam)) break;
		}
		int siz = sizes[i];

		String title = "DBJett " + nam + " Design  (";
			title += siz;
			title += "x" + siz;
			title += ")";

		Frame f = new Frame(title);
		DBJettFr dp = new DBJettFr();
		f.add("Center", dp);

		f.pack();
		f.setResizable(false);
		f.setLocation(newWinX, newWinY);
		newWinX += 12; newWinY += 10;
		canvasesUp += 1;
		f.show();
		f.setVisible(false);
		//f.dispose();
		// cp.applyPreset(0,false);
    }

    public int canvasesUp = 0;

    static Frame f2;
    static DBJettApplet sa;

    public static void main(String []args) {
		f2 = new Frame("Spiro 1.0");
		sa = new DBJettApplet();

		f2.add("Center",sa);
		f2.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				if (sa.canvasesUp > 0) {
					try {
						Toolkit.getDefaultToolkit().beep();
					} catch (SecurityException se) { }
				}
				else
					//System.exit(0);
					f2.dispose();
				}
			});
		sa.init();
		sa.start();
		f2.pack();
		f2.show();
    }
}
