import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Iterator; /** Monitors the count of the InputStreams available in this AppletContext */ public class StreamMonitor extends JApplet { Timer timer; public void init() { final JTextField num = new JTextField(20); num.setEditable(false); add(num); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent ae) { Iterator it = getAppletContext().getStreamKeys(); int count = 0; while(it.hasNext()) { it.next(); count++; } num.setText( "" + count ); } }; timer = new Timer(200, listener); timer.start(); System.out.println("Monitoring streams.."); } public void destroy() { timer.stop(); } }