View Javadoc
1 package net.sourceforge.selfesteem.applet; 2 3 /* 4 * %W% %E% 5 * 6 * Copyright 1997, 1998 by Sun Microsystems, Inc., 7 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. 8 * All rights reserved. 9 * 10 * This software is the confidential and proprietary information 11 * of Sun Microsystems, Inc. ("Confidential Information"). You 12 * shall not disclose such Confidential Information and shall use 13 * it only in accordance with the terms of the license agreement 14 * you entered into with Sun. 15 */ 16 17 import javax.swing.*; 18 import javax.swing.event.CellEditorListener; 19 import javax.swing.event.ChangeEvent; 20 import javax.swing.event.EventListenerList; 21 import java.util.EventObject; 22 23 /*** 24 * @version %I% %G% 25 * 26 * A base class for CellEditors, providing default implementations for all 27 * methods in the CellEditor interface and support for managing a series 28 * of listeners. 29 * 30 * @author Philip Milne 31 */ 32 33 public class AbstractCellEditor implements CellEditor { 34 35 protected EventListenerList listenerList = new EventListenerList(); 36 37 public Object getCellEditorValue() { 38 return null; 39 } 40 41 public boolean isCellEditable(EventObject e) { 42 return true; 43 } 44 45 public boolean shouldSelectCell(EventObject anEvent) { 46 return false; 47 } 48 49 public boolean stopCellEditing() { 50 return true; 51 } 52 53 public void cancelCellEditing() { 54 } 55 56 public void addCellEditorListener(CellEditorListener l) { 57 listenerList.add(CellEditorListener.class, l); 58 } 59 60 public void removeCellEditorListener(CellEditorListener l) { 61 listenerList.remove(CellEditorListener.class, l); 62 } 63 64 /*** 65 * Notify all listeners that have registered interest for 66 * notification on this event type. 67 * @see javax.swing.event.EventListenerList 68 */ 69 protected void fireEditingStopped() { 70 // Guaranteed to return a non-null array 71 Object[] listeners = listenerList.getListenerList(); 72 // Process the listeners last to first, notifying 73 // those that are interested in this event 74 for (int i = listeners.length - 2; i >= 0; i -= 2) { 75 if (listeners[i] == CellEditorListener.class) { 76 ((CellEditorListener) listeners[i + 1]).editingStopped(new ChangeEvent(this)); 77 } 78 } 79 } 80 81 /*** 82 * Notify all listeners that have registered interest for 83 * notification on this event type. 84 * @see javax.swing.event.EventListenerList 85 */ 86 protected void fireEditingCanceled() { 87 // Guaranteed to return a non-null array 88 Object[] listeners = listenerList.getListenerList(); 89 // Process the listeners last to first, notifying 90 // those that are interested in this event 91 for (int i = listeners.length - 2; i >= 0; i -= 2) { 92 if (listeners[i] == CellEditorListener.class) { 93 ((CellEditorListener) listeners[i + 1]).editingCanceled(new ChangeEvent(this)); 94 } 95 } 96 } 97 }

This page was automatically generated by Maven