Java JList filterDataList(JList jList, List dataList, String text)

Here you can find the source of filterDataList(JList jList, List dataList, String text)

Description

filter Data List

License

Open Source License

Declaration

public static void filterDataList(JList jList, List dataList, String text) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

import javax.swing.JList;

public class Main {
    public static void filterDataList(JList jList, List dataList, String text) {
        jList.setListData(new Object[] {});

        List newList = new ArrayList();
        dataList.stream().filter((ob) -> (ob.toString().toLowerCase().startsWith(text.toLowerCase())))
                .forEach((ob) -> {/*from w  w  w. j  av  a2s.c  o  m*/
                    newList.add(ob);
                });

        jList.setListData(newList.toArray());
    }
}

Related

  1. applyDefaultProperties(final JList comp)
  2. clearList(JList list)
  3. ensureCustomBackgroundStored(JList comp)
  4. ensureRangeIsVisible(JList list, int top, int bottom)
  5. getStoredBackground(JList comp)
  6. getVisibleRowCount(JList list)
  7. indexList(JList list, Object object)
  8. indexOf(JList jList, Object obj)