Hi folks, my JList should show several entries where one is selected. On the other hand the JList should be disabled so that the user cannot select a different entry. In this use case the JList is only used to show information and not to handle user events. How can I do this? I don't want to use "JList.setEnabled(false)", because then the entries are gray-colored and hard to see, especially the selected one! Thanks in advance!
save the state of the list in some Map or List somewhere, then add a MouseListener to the JList, and when you detect a mouseclick, use JList.setSelection() (I think that's what it's name is) to set it back to normal again. Ehrr... perhaps this isnt the most beautiful solution, take another look through the api-docs before you do it
Thanks for your help guys, but meanwhile I found a solution by my own. I use an own CellRenderer defining my JList-Cells that I assign to my JList by myList.setCellRenderer( new MyCellRenderer); If someone has a similar problem he should look into the API pages of SWING (CellRenderer, etc.)
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop