Java JList Model toList(ListModel model)

Here you can find the source of toList(ListModel model)

Description

to List

License

Open Source License

Declaration

public static List toList(ListModel model) 

Method Source Code

//package com.java2s;
/*/*from  ww  w. j a  v  a  2 s  .  com*/
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
 *        
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 */

import java.util.ArrayList;

import java.util.List;

import javax.swing.ListModel;

public class Main {
    public static List toList(ListModel model) {
        ArrayList list = new ArrayList(model.getSize());
        for (int i = 0; i < model.getSize(); i++) {
            list.add(model.getElementAt(i));
        }

        return (list);
    }
}

Related

  1. remove(final DefaultListModel list, final int[] indices)
  2. removeAll(DefaultListModel m, List o)
  3. removeFromList(String path, DefaultListModel model, JList list)
  4. setListModel(ListModel model, JList list)
  5. toDefaultListModel(ArrayList list)
  6. toListModel(final List elements)