List of utility methods to do JList
void | applyDefaultProperties(final JList> comp) Sets default background and foreground color as well as a default font for the specified component. if (comp == null) { return; applyProperties(comp, "List.background", "List.foreground", "List.font"); |
void | clearList(JList list) fillList setListModel(generateListModel(), list); |
void | ensureCustomBackgroundStored(JList comp) ensure Custom Background Stored if (getStoredBackground(comp) != null) return; Color background = comp.getBackground(); if ((background == null) || (background instanceof UIResource) || (background == WARNING_BACKGROUND) || (background == ERROR_BACKGROUND)) return; comp.putClientProperty(STORED_BACKGROUND_KEY, background); |
void | ensureRangeIsVisible(JList list, int top, int bottom) ensure Range Is Visible int size = list.getModel().getSize(); if (top < 0) { top = 0; if (bottom >= size) { bottom = size - 1; Rectangle cellBounds = list.getCellBounds(top, bottom); ... |
void | filterDataList(JList jList, List dataList, String text) filter Data List jList.setListData(new Object[] {}); List newList = new ArrayList(); dataList.stream().filter((ob) -> (ob.toString().toLowerCase().startsWith(text.toLowerCase()))) .forEach((ob) -> { newList.add(ob); }); jList.setListData(newList.toArray()); |
Color | getStoredBackground(JList comp) get Stored Background return (Color) comp.getClientProperty(STORED_BACKGROUND_KEY);
|
int | getVisibleRowCount(JList list) get Visible Row Count return list.getLastVisibleIndex() - list.getFirstVisibleIndex() + 1;
|
int | indexList(JList list, Object object) index List ListModel model = list.getModel(); if (model == null) { model = new DefaultListModel(); list.setModel(model); ; if (model instanceof DefaultListModel) { DefaultListModel listModel = (DefaultListModel) model; ... |
int | indexOf(JList jList, Object obj) index Of ListModel model = jList.getModel(); int i; for (i = model.getSize() - 1; i >= 0; i--) if (model.getElementAt(i) == obj) break; return i; |
boolean | isDoubleClick(MouseEvent evt, JList lst, JButton btn) Enable the associated button if single click. if (lst.getMinSelectionIndex() >= 0) { switch (evt.getClickCount()) { case 1: btn.setEnabled(true); break; case 2: if (btn.isEnabled()) { return true; ... |