package W3C.PICS;
import java.awt.*;

/**
 * AddButton is used with the list and scrollbars in the filter creation interface
 */
class AddButton extends Button
{
 public AddButton(List l,TextComponent minText,TextComponent maxText)
 {
    super("Add");
    RangeList=l;
    this.maxText=maxText;
    this.minText=minText;
 }

 public boolean handleEvent(Event evt)
 {
    try
      {

        Double.valueOf(minText.getText()).doubleValue();
        Double.valueOf(maxText.getText()).doubleValue();
        RangeList.addItem(minText.getText() + " - " + maxText.getText());
      }
    catch (Exception e)
      {}

    return super.handleEvent(evt);
 }

 private List RangeList;
 private TextComponent maxText;
 private TextComponent minText;


}

/**
 * DelButton is used with the list and scrollbars in the filter creation interface
 */
class DelButton extends Button
{
 public DelButton(List l)
 {
    super("Del");
    RangeList=l;
 }

/**
 * The current selected item in the assoicated list is deleted
 */
 public boolean handleEvent(Event evt)
 {
   int i=RangeList.getSelectedIndex();
    System.out.println("button "+i);
   if (i!=-1)
    {
     RangeList.delItem(i);
    }
    return super.handleEvent(evt);
 }
 private List RangeList;

}