import java.awt.*; import java.applet.Applet; import java.awt.event.*; import java.awt.image.*; public class PowderFlow extends Applet implements WindowListener,MouseListener,MouseMotionListener,Runnable,ActionListener,ComponentListener { final static int size=6; boolean[][] cell,settled; Button fall,stop,erase; Image offscreen; Frame frame; boolean running=false; boolean falling=false; boolean state=true; static public void main(String[] args) { main(); } public void init() { main(); } static void main() { PowderFlow pf=new PowderFlow(); pf.frame=new Frame("粉体流れ"); pf.frame.setSize(240,350); Panel panel=new Panel(new GridLayout()); ((Button)panel.add(pf.fall=new Button("ふる"))).addActionListener(pf); ((Button)panel.add(pf.stop=new Button("やむ"))).addActionListener(pf); ((Button)panel.add(pf.erase=new Button("けす"))).addActionListener(pf); pf.frame.add(panel,BorderLayout.NORTH); pf.frame.addWindowListener(pf); pf.addMouseListener(pf); pf.addMouseMotionListener(pf); pf.addComponentListener(pf); pf.frame.add(pf,BorderLayout.CENTER); pf.frame.show(); } public void setCell() { running=false; falling=false; cell=new boolean[getSize().height/size][getSize().width/size]; settled=new boolean[getSize().height/size][getSize().width/size]; for (int y=0;y