Code example for JList

Methods: getBackgroundgetSelectionBackgroundgetSelectionForeground

0
	@Override 
	public Component getListCellRendererComponent(JList list, Object value, int index,
			boolean isSelected, boolean cellHasFocus) {
		setValue(value == null ? "" : value, isSelected);
		if (isSelected) {
			setBackground(list.getSelectionBackground());
			setForeground(list.getSelectionForeground());
		} else { 
			setBackground(list.getBackground());
			setForeground(CORNFLOWER);
		} 
		return this;
	} 
 
	private void setValue(Object value, boolean isSelected) {
		String name = value.toString();
		int lastSlash = name.lastIndexOf('/');
		if (!isSelected && lastSlash > -1) {
			String group = name.substring(0, lastSlash + 1);
			String repo = name.substring(lastSlash + 1);
Contextual code suggestions in your IDE  Get Codota for Java