/*
 * Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package javax.swing;

import javax.swing.event.ListDataListener;

This interface defines the methods components like JList use to get the value of each cell in a list and the length of the list. Logically the model is a vector, indices vary from 0 to ListDataModel.getSize() - 1. Any change to the contents or length of the data model must be reported to all of the ListDataListeners.
Author:Hans Muller
Type parameters:
  • <E> – the type of the elements of this model
See Also:
Since:1.2
/** * This interface defines the methods components like JList use * to get the value of each cell in a list and the length of the list. * Logically the model is a vector, indices vary from 0 to * ListDataModel.getSize() - 1. Any change to the contents or * length of the data model must be reported to all of the * ListDataListeners. * * @param <E> the type of the elements of this model * * @author Hans Muller * @see JList * @since 1.2 */
public interface ListModel<E> {
Returns the length of the list.
Returns:the length of the list
/** * Returns the length of the list. * @return the length of the list */
int getSize();
Returns the value at the specified index.
Params:
  • index – the requested index
Returns:the value at index
/** * Returns the value at the specified index. * @param index the requested index * @return the value at <code>index</code> */
E getElementAt(int index);
Adds a listener to the list that's notified each time a change to the data model occurs.
Params:
  • l – the ListDataListener to be added
/** * Adds a listener to the list that's notified each time a change * to the data model occurs. * @param l the <code>ListDataListener</code> to be added */
void addListDataListener(ListDataListener l);
Removes a listener from the list that's notified each time a change to the data model occurs.
Params:
  • l – the ListDataListener to be removed
/** * Removes a listener from the list that's notified each time a * change to the data model occurs. * @param l the <code>ListDataListener</code> to be removed */
void removeListDataListener(ListDataListener l); }