/** * A simple dialog used by the MemoryStatus and Response test panels. * * This is loosly based on StatusMemory.java by Jef Poskanzer, from * his public distribution on <http://www.acme.com> * * Copyright &copy; 1996-1998 Martin Minow. All Rights Reserved.<p> * * Permission to use, copy, modify, and redistribute this software and its * documentation for personal, non-commercial use is hereby granted provided that * this copyright notice and appropriate documentation appears in all copies. This * software may not be distributed for fee or as part of commercial, "shareware," * and/or not-for-profit endevors including, but not limited to, CD-ROM collections, * online databases, and subscription services without specific license.<p> * * @author <a href="mailto:minow@apple.com">Martin Minow</a> * @version 1.0 * Set tabs every 4 characters. */import java.applet.*;import java.awt.*;import java.util.*;import java.lang.*;public class UpdateIntervalPanel extends Panel{	public static final long	defaultUpdateInterval = 2000;	private long		updateInterval			= defaultUpdateInterval;	private Button		updateIntervalButton	= new Button("Set Update Interval");	private TextField	updateIntervalField		= new TextField(					Long.toString(defaultUpdateInterval), 6);	public UpdateIntervalPanel()	{		updateIntervalButton.setBackground(Color.white);		updateIntervalField.setBackground(Color.white);		setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2));		setFont(GetDialogFont.getFont());		setBackground(Color.gray);		add(updateIntervalField);		add(new Label("Msec"));		add(updateIntervalButton);	}	/*	 * Accessors.	 */	public long getUpdateInterval()	{		return (updateInterval);	}	public void setUpdateInterval(			long		updateInterval		)	{		this.updateInterval = updateInterval;		updateIntervalField.setText(Long.toString(updateInterval));	}			/*	 * We use action to remain Java 1.0.2 complient	 */	public boolean action(			Event			event,			Object			arg		)	{		boolean		result		= false;		if (event.target == updateIntervalButton) {			try {				long updateInterval = Long.parseLong(updateIntervalField.getText());				if (updateInterval <= 0) {					throw new NumberFormatException("Value must be positive");				}				/*				 * This is kind of hokey -- we change the event target				 * to ourself, and throw it to the enclosing container				 * and then return false so it's still in the food chain.				 */				this.updateInterval = updateInterval;				event.target = this;							}			catch (NumberFormatException e) {				/*				 * This should be replaced by a dialog.				 */				System.out.println("Invalid sleeptime: " + e);				result = true;			}		}		return (result);	}}