1 16 package swingwtx.swing; 17 18 import java.util.*; 19 20 import swingwtx.swing.event.*; 21 22 27 public abstract class AbstractCellEditor implements CellEditor { 28 29 protected Vector listeners = new Vector(); 30 31 public boolean isCellEditable(EventObject e) { 32 return true; 33 } 34 35 public boolean shouldSelectCell(EventObject anEvent) { 36 return true; 37 } 38 39 public boolean stopCellEditing() { 40 fireEditingStopped(); 41 return true; 42 } 43 44 public void cancelCellEditing() { 45 fireEditingCanceled(); 46 } 47 48 49 public void addCellEditorListener(CellEditorListener l) { 50 listeners.add(l); 51 } 52 53 public void removeCellEditorListener(CellEditorListener l) { 54 listeners.remove(l); 55 } 56 57 public CellEditorListener[] getCellEditorListeners() { 58 if (listeners.size() == 0) return null; 59 CellEditorListener[] l = new CellEditorListener[listeners.size()]; 60 for (int i = 0; i < listeners.size(); i++) 61 l[i] = (CellEditorListener) listeners.get(i); 62 return l; 63 } 64 65 protected void fireEditingStopped() { 66 for (int i = 0; i < listeners.size(); i++) { 67 ChangeEvent e = new ChangeEvent(this); 68 ((CellEditorListener) listeners.get(i)).editingStopped(e); 69 } 70 } 71 72 protected void fireEditingCanceled() { 73 for (int i = 0; i < listeners.size(); i++) { 74 ChangeEvent e = new ChangeEvent(this); 75 ((CellEditorListener) listeners.get(i)).editingCanceled(e); 76 } 77 } 78 } 79 | Popular Tags |