Here you can find the source of JListRemoveSelectedObject(javax.swing.JList list)
public static void JListRemoveSelectedObject(javax.swing.JList list)
//package com.java2s; /*//from w ww . j a v a2s.c om 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 JListRemoveSelectedObject(javax.swing.JList list) { Object sel = list.getSelectedValue(); if (sel != null) { javax.swing.ListModel lm = list.getModel(); Object[] newList = new Object[lm.getSize() - 1]; int cur = 0; for (int i = 0; i < lm.getSize(); i++) { if (lm.getElementAt(i) != sel) newList[cur++] = lm.getElementAt(i); } list.setListData(newList); } } }