Java JList Model toDefaultListModel(ArrayList list)

Here you can find the source of toDefaultListModel(ArrayList list)

Description

to Default List Model

License

Open Source License

Declaration

public static DefaultListModel toDefaultListModel(ArrayList<?> list) 

Method Source Code

//package com.java2s;
/**//  w w w .j  a v a2 s.c  o m
 * @(#)GUIUtil.java 1.0 26.09.06 (dd.mm.yy)
 *
 * Copyright (2003) Bro3
 * 
 * This program 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 2, or any later version.
 * 
 * This program 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 
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Boston, MA 02111.
 * 
 * Contact: bro3@users.sourceforge.net
 **/

import java.util.ArrayList;

import javax.swing.DefaultListModel;

public class Main {
    public static DefaultListModel toDefaultListModel(ArrayList<?> list) {

        DefaultListModel listModel = new DefaultListModel();

        for (int i = 0; i < list.size(); i++) {
            listModel.addElement(list.get(i));
        }

        return listModel;
    }
}

Related

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