Java JList Model indexesOf(DefaultListModel model, String sa[])

Here you can find the source of indexesOf(DefaultListModel model, String sa[])

Description

Returns all the indexes of elements in a model.

License

Open Source License

Parameter

Parameter Description
model The model to search in
sa The Strings to search for

Return

The indexes of the elements

Declaration

public static int[] indexesOf(DefaultListModel model, String sa[]) 

Method Source Code

//package com.java2s;
/*/*from   w  w w  . jav  a 2s  .c om*/
 * PackJacket - GUI frontend to IzPack to make Java-based installers
 * Copyright (C) 2008 - 2009  Amandeep Grewal, Manodasan Wignarajah
 *
 * PackJacket is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * PackJacket 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 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PackJacket.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.swing.DefaultListModel;

public class Main {
    /**
     * Returns all the indexes of elements in a model.
     * @param model The model to search in
     * @param sa The Strings to search for
     * @return The indexes of the elements
     */
    public static int[] indexesOf(DefaultListModel model, String sa[]) {
        int[] ia = new int[sa.length];
        for (int x = 0; x < sa.length; x++)
            ia[x] = model.indexOf(sa[x]);
        return ia;
    }
}

Related

  1. generateListModel()
  2. getDefaultListModel(JList list)
  3. getListModel()
  4. getListModel(T[] data)
  5. hasOnlyValue(final ListModel model, final Object value)
  6. indexOf(Object obj, ListModel model)
  7. listAsListModel(ArrayList list)
  8. listModelEquals(final ListModel lm, final ListModel lm2)
  9. remove(final DefaultListModel list, final int[] indices)