Originally posted by Eric Chang:
I have a list of all the files and sub directories within a JList. I want the files to just be listed and grayed out and not able to be selected. I want the directories to be selectable and not grayed out.
The part I'm stuck on is getting the JList to display selectable and unselectable items (not to mention the grayed out color of the unselectable items)...is this a case where I want to start messing around with the CellRenderer?
Yes. You want to set a cell renderer for the JList to display some items
in a greyed-out color. This is actually pretty simple. For example, to
grey-out every other item in the list:
This changes just how those items are drawn. It doesn't change whether
they can be selected or not. For that take a look at ListSelectionModel.