Code example for JList

Methods: getForegroundhasFocusisEnabledisFocusable

0
			return prototypeRenderer;
		} 
 
		// This will allow the look and feel to set anything in order to 
		// reflect the native OS 
		JLabel renderer = (JLabel) cellRenderer.getListCellRendererComponentlist,
			null, 
			index,
			selected,
			cellHasFocus
		); 
 
		renderer.setEnabled(list.isEnabled());
 
		// Update the renderer's properties by converting the value to 
		// something displayable (text, icon, tooltip) 
		updateRenderer(renderer, value);
 
		// If the list does not have the focus, show the selected cell has 
		// "partially" selected 
		if (selected         &&
		    !list.hasFocus() &&
		     list.isFocusable())
		{ 
			renderer.setForeground(list.getForeground());
			renderer.setBackground(UIManager.getColor("Panel.background"));
		} 
 
		// Grey out the icon 
		if (!list.isEnabled()                  &&
		    renderer.getIcon()         != null &&
		    renderer.getDisabledIcon() == null &&
		    renderer.getIcon() instanceof ImageIcon)
		{ 
			ImageIcon icon = (ImageIcon) renderer.getIcon();