1. /*
  2. * @(#)ListModel.java 1.16 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing;
  8. import javax.swing.event.ListDataListener;
  9. /**
  10. * This interface defines the methods components like JList use
  11. * to get the value of each cell in a list and the length of the list.
  12. * Logically the model is a vector, indices vary from 0 to
  13. * ListDataModel.getSize() - 1. Any change to the contents or
  14. * length of the data model must be reported to all of the
  15. * ListDataListeners.
  16. *
  17. * @version 0.0 03/01/97
  18. * @author Hans Muller
  19. * @see JList
  20. */
  21. public interface ListModel
  22. {
  23. /**
  24. * Returns the length of the list.
  25. * @return the length of the list
  26. */
  27. int getSize();
  28. /**
  29. * Returns the value at the specified index.
  30. * @param index the requested index
  31. * @return the value at <code>index</code>
  32. */
  33. Object getElementAt(int index);
  34. /**
  35. * Adds a listener to the list that's notified each time a change
  36. * to the data model occurs.
  37. * @param l the <code>ListDataListener</code> to be added
  38. */
  39. void addListDataListener(ListDataListener l);
  40. /**
  41. * Removes a listener from the list that's notified each time a
  42. * change to the data model occurs.
  43. * @param l the <code>ListDataListener</code> to be removed
  44. */
  45. void removeListDataListener(ListDataListener l);
  46. }