@SuppressWarnings("unchecked") public void setSelectedItem(Object item) { setSelectedIndex((item == null) ? -1 : ((List<Object>)listData).indexOf(item)); }
@SuppressWarnings("unchecked") public void setSelectedItem(Object item) { setSelectedIndex((item == null) ? -1 : ((List<Object>)listData).indexOf(item)); }
@Override public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) { ListButton listButton = (ListButton)getComponent(); listViewPopup.close(); int index = listView.getSelectedIndex(); listButton.setSelectedIndex(index); if (listButton.isRepeatable()) { listButton.press(); } return true; } };
@Override public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) { ListButton listButton = (ListButton)getComponent(); listViewPopup.close(); int index = listView.getSelectedIndex(); listButton.setSelectedIndex(index); if (listButton.isRepeatable()) { listButton.press(); } return true; } };
/** * Select the next enabled list item where the first character of the * rendered text matches the typed key (case insensitive). */ @Override public boolean keyTyped(Component component, char character) { boolean consumed = super.keyTyped(component, character); ListButton listButton = (ListButton)getComponent(); List<?> listData = listButton.getListData(); ListView.ItemRenderer itemRenderer = listButton.getItemRenderer(); char characterUpper = Character.toUpperCase(character); for (int i = listButton.getSelectedIndex() + 1, n = listData.getLength(); i < n; i++) { if (!listButton.isItemDisabled(i)) { String string = itemRenderer.toString(listData.get(i)); if (string != null && string.length() > 0) { char first = Character.toUpperCase(string.charAt(0)); if (first == characterUpper) { listButton.setSelectedIndex(i); consumed = true; break; } } } } return consumed; }
/** * Select the next enabled list item where the first character of the * rendered text matches the typed key (case insensitive). */ @Override public boolean keyTyped(Component component, char character) { boolean consumed = super.keyTyped(component, character); ListButton listButton = (ListButton)getComponent(); List<?> listData = listButton.getListData(); ListView.ItemRenderer itemRenderer = listButton.getItemRenderer(); character = Character.toUpperCase(character); for (int i = listButton.getSelectedIndex() + 1, n = listData.getLength(); i < n; i++) { if (!listButton.isItemDisabled(i)) { String string = itemRenderer.toString(listData.get(i)); if (string != null && string.length() > 0) { char first = Character.toUpperCase(string.charAt(0)); if (first == character) { listButton.setSelectedIndex(i); consumed = true; break; } } } } return consumed; }
listButton.setSelectedIndex(index); listButton.setSelectedIndex(index);
listButton.setSelectedIndex(index); listButton.setSelectedIndex(index);
@Override @SuppressWarnings("unchecked") public void load(Object context) { // Bind to list data if (listDataKey != null && listDataBindType != BindType.STORE && JSON.containsKey(context, listDataKey)) { Object value = JSON.get(context, listDataKey); List<?> listDataLocal; if (listDataBindMapping == null) { listDataLocal = (List<?>)value; } else { listDataLocal = listDataBindMapping.toListData(value); } setListData(listDataLocal); } // Bind to selected item if (selectedItemKey != null && selectedItemBindType != BindType.STORE && JSON.containsKey(context, selectedItemKey)) { Object item = JSON.get(context, selectedItemKey); int index; if (selectedItemBindMapping == null) { index = ((List<Object>)listData).indexOf(item); } else { index = selectedItemBindMapping.indexOf(listData, item); } setSelectedIndex(index); } }
@Override @SuppressWarnings("unchecked") public void load(Object context) { // Bind to list data if (listDataKey != null && listDataBindType != BindType.STORE && JSON.containsKey(context, listDataKey)) { Object value = JSON.get(context, listDataKey); List<?> listData; if (listDataBindMapping == null) { listData = (List<?>)value; } else { listData = listDataBindMapping.toListData(value); } setListData(listData); } // Bind to selected item if (selectedItemKey != null && selectedItemBindType != BindType.STORE && JSON.containsKey(context, selectedItemKey)) { Object item = JSON.get(context, selectedItemKey); int index; if (selectedItemBindMapping == null) { index = ((List<Object>)listData).indexOf(item); } else { index = selectedItemBindMapping.indexOf(listData, item); } setSelectedIndex(index); } }
listButton.setSelectedIndex(index); consumed = true; listButton.setSelectedIndex(index); consumed = true;
listButton.setSelectedIndex(index); consumed = true; listButton.setSelectedIndex(index); consumed = true;