Java JList Select removeSelectionFromList(JList fileList)

Here you can find the source of removeSelectionFromList(JList fileList)

Description

Removes the selected entry from the given list.

License

Open Source License

Parameter

Parameter Description
fileList a parameter

Declaration

public static void removeSelectionFromList(JList fileList) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.DefaultListModel;

import javax.swing.JList;

public class Main {
    /**/*www.  j  a v a  2  s  . c om*/
     * Removes the selected entry from the given list. If nothing is selected,
     * nothing will be removed.
     * 
     * @param fileList
     */
    public static void removeSelectionFromList(JList fileList) {
        if (fileList.getSelectedIndex() > -1) {
            ((DefaultListModel) fileList.getModel()).remove(fileList.getSelectedIndex());
        }
    }
}

Related

  1. linkEnabledToSelected(final JComponent component, final ListSelectionModel model)
  2. moveSelectedItems(JList list, int nrRows)
  3. moveSourceSelection(JList sourceList, boolean moveDown, boolean byPage)
  4. removeListSelectionListeners(final JList comp)
  5. removeSelectedListItems(JList sourceList)
  6. removeTypeSelectionListener(JList list)
  7. selectByTyping(javax.swing.JList list, javax.swing.JTextField textfield)
  8. selectRow(int row, ListSelectionModel model)
  9. selectStringInList(String string, JList list)