import java.applet.Applet; import java.awt.*; import java.awt.event.*; /* 8-Queens Applet, By Aaron Davidson This code is released in the public domain. The author would appreciate it if any derivatives or distributions retain this comment & credit. */ public class QueensApplet extends Applet implements ActionListener { Button solve = new Button("Solve"); Button clear = new Button("Clear"); Board b = new Board(); public void init() { setLayout(new BorderLayout()); add("Center", b); Panel bPanel = new Panel(); add("South", bPanel); bPanel.setLayout(new GridLayout(1,5)); bPanel.add(new Label(" ")); bPanel.add(clear); bPanel.add(new Label(" ")); bPanel.add(solve); bPanel.add(new Label(" ")); clear.addActionListener(this); solve.addActionListener(this); } public void actionPerformed(ActionEvent e) { if (e.getSource() == clear) { b.initBoard(); b.paint(b.getGraphics()); } else if (e.getSource() == solve) { b.initBoard(); b.paint(b.getGraphics()); b.solve(0); } } }