Java JList Add Remove JListAddObject(javax.swing.JList list, Object item)

Here you can find the source of JListAddObject(javax.swing.JList list, Object item)

Description

J List Add Object

License

CDDL license

Declaration

public static void JListAddObject(javax.swing.JList list, Object item) 

Method Source Code

//package com.java2s;
/*//from ww  w.  j  ava2  s . co m
Copyright (c) 2013 eBay, Inc.
This program is licensed under the terms of the eBay Common Development and
Distribution License (CDDL) Version 1.0 (the "License") and any subsequent  version 
thereof released by eBay.  The then-current version of the License can be found 
at http://www.opensource.org/licenses/cddl1.php and in the eBaySDKLicense file that 
is under the eBay SDK ../docs directory.
*/

public class Main {
    public static void JListAddObject(javax.swing.JList list, Object item) {
        javax.swing.ListModel lm = list.getModel();
        Object[] newList = new Object[lm.getSize() + 1];
        for (int i = 0; i < lm.getSize(); i++) {
            newList[i] = lm.getElementAt(i);
        }
        newList[lm.getSize()] = item;
        list.setListData(newList);
    }
}

Related

  1. addItemJList(javax.swing.JList jlist, String item)
  2. addToList(JList list, Object object)
  3. fillList(Collection anList, JList anJList)
  4. fillList(JList aListComponent, String theList, boolean removeQuotes)
  5. fillList(Object[] elements, JList list)
  6. removeAllListItems(JList sourceList)
  7. removeFromList(JList list, Object object)
  8. removeItemJList(javax.swing.JList jlist)