FileDocCategorySizeDatePackage
EmailEditor.javaAPI DocExample2289Thu Oct 24 20:14:26 BST 2002None

EmailEditor

public class EmailEditor extends JTextField implements CellEditor

Fields Summary
String
value
Vector
listeners
Constructors Summary
public EmailEditor()


  // Mimic all the constructors people expect with text fields.
     this("", 5); 
public EmailEditor(String s)

 this(s, 5); 
public EmailEditor(int w)

 this("", w); 
public EmailEditor(String s, int w)

 
    super(s, w); 
    // Listen to our own action events so that we know when to stop editing.
    addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        if (stopCellEditing()) { fireEditingStopped(); }
      }
    });
  
Methods Summary
public voidaddCellEditorListener(javax.swing.event.CellEditorListener cel)

    listeners.addElement(cel);
  
public voidcancelCellEditing()

 setText(""); 
protected voidfireEditingStopped()

    if (listeners.size() > 0) {
      ChangeEvent ce = new ChangeEvent(this);
      for (int i = listeners.size() - 1; i >= 0; i--) {
        ((CellEditorListener)listeners.elementAt(i)).editingStopped(ce);
      }
    }
  
public java.lang.ObjectgetCellEditorValue()

 return value; 
public booleanisCellEditable(java.util.EventObject eo)

    if ((eo == null) || 
        ((eo instanceof MouseEvent) && 
         (((MouseEvent)eo).isMetaDown()))) {
      return true;
    }
    return false;
  
public voidremoveCellEditorListener(javax.swing.event.CellEditorListener cel)

    listeners.removeElement(cel);
  
public booleanshouldSelectCell(java.util.EventObject eo)

 return true; 
public booleanstopCellEditing()

    try {
      String tmp = getText();
      int at = tmp.indexOf("@");
      if (at != -1) {
        value = tmp;
        return true;
      }
      return false;
    }
    catch (Exception e) {
      // Something went wrong (most likely we don't have a valid integer).
      return false;
    }