import java.awt.*; import java.applet.Applet; import java.awt.event.*; import java.awt.image.*; public class BallisticDeposition extends Applet implements WindowListener,MouseListener,MouseMotionListener,Runnable,ActionListener,ComponentListener { final static int size=6; boolean[][] cell; 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() { BallisticDeposition bd=new BallisticDeposition(); bd.frame=new Frame("Ballistic Deposition"); bd.frame.setSize(240,350); Panel panel=new Panel(new GridLayout()); ((Button)panel.add(bd.fall=new Button("ふる"))).addActionListener(bd); ((Button)panel.add(bd.stop=new Button("やむ"))).addActionListener(bd); ((Button)panel.add(bd.erase=new Button("けす"))).addActionListener(bd); bd.frame.add(panel,BorderLayout.NORTH); bd.frame.addWindowListener(bd); bd.setBackground(Color.white); bd.addMouseListener(bd); bd.addMouseMotionListener(bd); bd.addComponentListener(bd); bd.frame.add(bd,BorderLayout.CENTER); bd.frame.show(); } public void setCell() { running=false; falling=false; cell=new boolean[getSize().height/size][getSize().width/size]; for (int y=0;y