
//------------------------------------------------------------------------------
// myTextField.java:
//------------------------------------------------------------------------------

import java.awt.*;

public class myTextField extends TextField
{
	Color bg_color;
	SetupButton parent;
	dataCompMember data;
	
	// Constructor
	//--------------------------------------------------------------------------
	public myTextField (SetupButton p,dataCompMember dc,String s)
	{
		super(s);
		parent = p;
		data = dc;
	}
	
	public myTextField (SetupButton p,String s,Color c)
	{
		super(s);
		bg_color = c;
		parent = p;
		data = null;
	}
	
	public myTextField (SetupButton p,String s)
	{
		super(s);
		bg_color = null;
		parent = p;
		data = null;
	}


    // Event handlers
	//--------------------------------------------------------------------------
    // Pressing the return key while the cursor is in the field causes this event
	public boolean action(Event event, Object obj)
	{
		if(parent.all)  {
			Color c = this.getBackground();
			if(c != bg_color)  {
				setColor(bg_color);
			    return(true);
			}  else  {
				setColor(Color.white);
			    return(false);
			}
		}  else  {
			if(parent.mc_choice.getSelectedIndex() == 1)  {
				// pop up the distribution dialog box
				Double z = new Double(this.getText());
				data.setdvalue(z.doubleValue());
				DistributionDialog dd = new DistributionDialog(parent,data,true);
				dd.popup();		
			}
		}
		return(true);
	}
	
	private void setColor(Color c)
	{
		this.setBackground(c);
	}
	
	public void setFieldColor(Color c)
	{
		if(c != null)  {
			this.setBackground(c);
		}  else  {
			System.out.println("c is null");
		}
	}


}


