import java.awt.*; import java.applet.Applet; import java.awt.event.*; import java.awt.image.*; public class DendriticGrowth extends Applet implements WindowListener,MouseListener,MouseMotionListener,Runnable,ActionListener,ComponentListener { final static int space=0,north=1,south=2,east=3,west=4,settled=5; final static int size=6; int[][] cell; Button sprinkle,shake,erase; Image offscreen; Frame frame; boolean running=false; static public void main(String[] args) { main(); } public void init() { main(); } static void main() { DendriticGrowth dg=new DendriticGrowth(); dg.frame=new Frame("Dendritic Growth"); dg.frame.setSize(240,240); Panel panel=new Panel(new GridLayout()); ((Button)panel.add(dg.sprinkle=new Button("まく"))).addActionListener(dg); ((Button)panel.add(dg.shake=new Button("ふる"))).addActionListener(dg); ((Button)panel.add(dg.erase=new Button("けす"))).addActionListener(dg); dg.frame.add(panel,BorderLayout.NORTH); dg.frame.addWindowListener(dg); dg.addMouseListener(dg); dg.addMouseMotionListener(dg); dg.addComponentListener(dg); dg.frame.add(dg,BorderLayout.CENTER); dg.frame.show(); } public void setCell() { cell=new int[getSize().height/size][getSize().width/size]; for (int y=0;y