1 /* 2 * @(#)ListModel.java 1.17 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package javax.swing; 9 10 import javax.swing.event.ListDataListener; 11 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 * @return the length of the list 29 */ 30 int getSize(); 31 32 /** 33 * Returns the value at the specified index. 34 * @param index the requested index 35 * @return the value at <code>index</code> 36 */ 37 Object getElementAt(int index); 38 39 /** 40 * Adds a listener to the list that's notified each time a change 41 * to the data model occurs. 42 * @param l the <code>ListDataListener</code> to be added 43 */ 44 void addListDataListener(ListDataListener l); 45 46 /** 47 * Removes a listener from the list that's notified each time a 48 * change to the data model occurs. 49 * @param l the <code>ListDataListener</code> to be removed 50 */ 51 void removeListDataListener(ListDataListener l); 52 } 53 54