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