import java.awt.*; public class Diamond extends java.applet.Applet { TextField tf; TextArea ta; String stars = "*******************"; String spaces = " "; int k; public void init() { tf = new TextField("Hello "); ta = new TextArea(20, 20); add(tf); add(ta); } public boolean action(Event e, Object arg) { if (e.target == tf) { tf.setText("Goodbye"); k = 0; while (k < 10) { ta.appendText(spaces.substring(0,10-k) + stars.substring(0,2*k+1)+"\n"); k = k + 1; } k = 1; while (k < 10) { ta.appendText(spaces.substring(0,1+k) + stars.substring(0,19-2*k)+"\n"); k = k + 1; } return true; } return false; } }