import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/**
 * Tama on samalla appletti (sovelma) etta applikaatio (sovellus). 
 * HUOM! Nappulat eivat tule nakyviin appletissa! Mieti miksi!
 */
public class MyApplet extends Applet implements ActionListener
{
	public void paint(Graphics g)
	{
		g.fillRect(10, 10, 50, 80);
	}

	public Dimension getPreferredSize()
	{
		return new Dimension(100, 100);
	}

	public void actionPerformed(ActionEvent e)
	{
		System.out.println(((Button)e.getSource()).getLabel());
	}

	public static void main(String[] args)
	{
		Button b;

		Frame f = new Frame("Testi-ikkuna");
		f.setLayout(new BorderLayout());
		MyApplet a = new MyApplet();
		f.add(a);

		Panel p = new Panel();
		p.setLayout(new FlowLayout());
		f.add(p, BorderLayout.SOUTH);
		b = new Button("1"); p.add(b); b.addActionListener(a);
		b = new Button("2"); p.add(b); b.addActionListener(a);
		p.add(new Button("3"));
		p.add(new Button("4"));

		f.addWindowListener(new MyAdapter());
		f.pack();
		f.show();
	}
}

/**
 * Pelkastaan ikkunan sulkemiseen.
 */
class MyAdapter extends WindowAdapter
{
	public void windowClosing(WindowEvent e) { System.exit(0); }
}

