Java JList Model addAll(DefaultListModel m, List o)

Here you can find the source of addAll(DefaultListModel m, List o)

Description

Adds all Elements from a List to a DefaultListModel

License

Open Source License

Parameter

Parameter Description
m the Model to add the Entries to
o the Entries to add

Declaration

public static <B> void addAll(DefaultListModel<B> m, List<B> o) 

Method Source Code

//package com.java2s;
/**//  ww w.  j  a v  a 2s . c  o m
*   YM2151 - Midi Controller Software for Arduino Shield
*   (C) 2016  Marcel Wei?
*
*   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 3 of the License, or
*   (at your option) 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, see <http://www.gnu.org/licenses/>.
*/

import java.util.List;
import javax.swing.DefaultListModel;

public class Main {
    /**
     * Adds all Elements from an Array to a DefaultListModel
     * @param m the Model to add the Entries to
     * @param o the Entries to add
     * */
    public static <B> void addAll(DefaultListModel<B> m, B[] o) {
        for (int i = 0; i < o.length; i++) {
            m.addElement(o[i]);
        }
    }

    /**
     * Adds all Elements from a List to a DefaultListModel
     * @param m the Model to add the Entries to
     * @param o the Entries to add
     * */
    public static <B> void addAll(DefaultListModel<B> m, List<B> o) {
        for (int i = 0; i < o.size(); i++) {
            m.addElement(o.get(i));
        }
    }
}

Related

  1. add(final DefaultListModel model, final Collection collection)
  2. canHandleModel(JList list)
  3. collectionListModel(Collection collection)
  4. createDefaultListModel(final Object... elements)
  5. createList(final ListModel model)

  6. HOME | Copyright © www.java2s.com 2016