// The "BlockButton" class. import java.applet.*; import java.awt.*; public class BlockButton extends Applet { public boolean action (Event e, Object o) { Graphics g = getGraphics (); g.setColor(Color.green); g.fillRect( (int)(Math.random()*getSize().width),//randomly chooses where to put the rectangle (int)(Math.random()*getSize().height), 20, 20);// 20 is the size of the rectangle return true; } public void init () { Button button = new Button("Draw Block");//labels a button for users to press add(button);//draws the button } // init method } // BlockButton class