FileDocCategorySizeDatePackage
EditorTextField.javaAPI DocExample2592Mon Nov 09 12:45:50 GMT 1998None

EditorTextField

public class EditorTextField extends JTextField implements CellEditor

Fields Summary
Integer
value
Vector
listeners
private static final int
minWidth
Constructors Summary
public EditorTextField()


  // mimic all of the constructors people expect with text fields
     this("", 5); 
public EditorTextField(String s)

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

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

 
    super(s, w); 
    // listen to our own action events, so 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 voidsetBounds(java.awt.Rectangle r)

    r.width = Math.max(minWidth, r.width);
    super.setBounds(r);
  
public voidsetBounds(int x, int y, int w, int h)

    w = Math.max(minWidth, w);
    super.setBounds(x, y, w, h);
  
public booleanshouldSelectCell(java.util.EventObject eo)

 return true; 
public booleanstopCellEditing()

    try {
      value = Integer.valueOf(getText());
      return true;
    }
    catch (Exception e) {
      // something went wrong (most likely we don't have a valid integer)
      return false;
    }