JList ListModel to List - Java Swing

Java examples for Swing:JList

Description

JList ListModel to List

Demo Code


//package com.java2s;

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));
        }/*ww  w.jav a2 s .  c o  m*/

        return (list);
    }
}

Related Tutorials