/* Copyright 2002 Rujith de Silva. First written in 1996, source-file lost and re-created based on the class file. Modified 2002-04-04. */ package rujith.pentominoes; import java.applet.Applet; import java.awt.Button; import java.awt.Event; import java.awt.FlowLayout; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * Applet to start off the pentominoes BoardControls. */ public class PentoStart extends Applet { private BoardControls f; private Button restart; /** * Initialize the applet. */ public void init() { this.setLayout(new FlowLayout()); this.restart = new Button("Restart"); this.restart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PentoStart.this.startFrame(); } }); this.add(new Label("Pentominoes")); this.add(this.restart); this.resize(200,100); } // Restart the BoardControls if it had been closed. private void startFrame() { if (this.f != null) { // Get rid of the old BoardControls. if (! this.f.boardHere) { this.f.hide(); this.f = null; } } // Start a new BoardControls going if necessary if (this.f == null) { this.f = new BoardControls(); this.f.show(); } } /** * Start the applet going. */ public void start() { this.startFrame(); } }