FileDocCategorySizeDatePackage
TextComp.javaAPI DocJMF 2.1.1e1615Mon May 12 12:20:52 BST 2003com.sun.media.ui

TextComp

public class TextComp extends BasicComp implements ActionListener

Fields Summary
String
value
int
size
boolean
mutable
Label
compLabel
TextField
compText
Constructors Summary
public TextComp(String label, String initial, int size, boolean mutable)

	super(label);
	this.value = initial;
	this.size = size;
	this.mutable = mutable;

	setLayout( new BorderLayout() );
	Label lab = new Label(label, Label.LEFT);
	add("West", lab);
	if (!mutable) {
	    compLabel = new Label(initial, Label.LEFT);
	    add("Center", compLabel);
	} else {
	    compText = new TextField(initial, size);
	    add("Center", compText);
	    compText.addActionListener(this);
	}
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent ae)

	informListener();
    
public floatgetFloatValue()

	value = getValue();
	try {
	    float retVal = Float.valueOf(value).floatValue();
	    return retVal;
	} catch (NumberFormatException nfe) {
	    return 0.0f;
	}
    
public intgetIntValue()

	value = getValue();
	try {
	    int retVal = Integer.valueOf(value).intValue();
	    return retVal;
	} catch (NumberFormatException nfe) {
	    return 0;
	}
    
public java.lang.StringgetValue()

	if (mutable) {
	    return compText.getText();
	} else {
	    return compLabel.getText();
	}
    
public voidsetValue(java.lang.String s)

	value = s;
	if (mutable) {
	    compText.setText(s);
	} else {
	    compLabel.setText(s);
	}
	repaint();