import awb.*; import java.awt.*; import java.awt.event.*; public class DiaParms extends java.applet.Applet implements ActionListener { IntField gSize; TextArea ta; Button bDraw; String stars = "*******************"; String spaces = " "; public void init() { gSize = new IntField(10); ta = new TextArea(20, 20); ta.setFont(new Font("Monospaced", Font.BOLD, 12)); bDraw = new Button("Draw"); bDraw.addActionListener(this); add(gSize); add(bDraw); add(ta); } void Dia(int sz) { int k = 0; while (k < sz) { ta.append(spaces.substring(0,10-k) + stars.substring(0,2*k+1)+"\n"); k = k + 1; } } void Mond(int sz) { int k = sz; while (k > 0) { k = k - 1; ta.append(spaces.substring(0,10-k) + stars.substring(0,2*k+1)+"\n"); } } public void actionPerformed(ActionEvent event) { int sz; Object cause = event.getSource(); if (cause == bDraw) { sz = gSize.getInt(); Dia(sz); Mond(sz-1); } } }