// This Class is (c)opyright 1999 by Geoff Knagge. It may be freely used
// for any non-commercial purpose on the following conditions:
//   1.	You indemnify the copyright holder of all possible liability
//  	resulting from its use.
//   2.	You provide a link back to the source of this file, that is
//	http://browse.to/gogogeoff
//
// Use of this class shows your agreement to the above.

import java.awt.*;

public class DropList extends Panel {
// A simple class which places a label and Choice (pull down list)
// next to each other in a panel... The choice contains a customisable
// first entry, followed by a list of integers.

	Choice data;

	public int getValue() {
		return data.getSelectedIndex();
	}

	public DropList(String name, String firstlabel, int firstnum, 
			int endnum, int def)  {
	// input : 	text for the label,
	//		Text for the first entry in the Choice list,
	//		the first number to display,
	//		the last number to display,
	//		the index of the default choice

		setLayout(new GridLayout(1,2));  // 1 row, 2 columns
		Label namelab = new Label(name);

		data = new Choice();
		if (firstlabel!=null) data.add("Unlimited");
		for (int cnt=firstnum; cnt<=endnum; cnt++)
			data.add(Integer.toString(cnt));

		data.select(def);  // set the default

		add(namelab);   // add the label first
		add(data);      // then the Choice next to it.
	}
}