Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection in disabled JList 1

Status
Not open for further replies.

kmcculler

Programmer
Jul 5, 2000
81
0
0
US
Hi, I've got a lil prob with a JList can somebody help?

Setup: My JList displays a list of items and allows multiple selections. Some, none, or all of the items (data dependent) are shown to be selected when the list is created. The user can change the selected items and save... this all works fine.
However, under certain condidtions a user may be in view-only mode so they can view any item, but can't change them. So the list is displayed, but disabled [ie. setEnabled(false)].

Problem: When the user is in a read only mode (the JList is disabled), the entire list is greyed out and I can't visually tell what is selected from what isn't. Is there a way that I can show the users that this JList is disabled AND that some of the items are still selected?

Kris McCuller
 
I've tried this and the light blue selection bar remains clearly visible when the JList is disabled.

Can you post the relevent bits of your code, especially the bits which create and configure the JList?

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Ooops, I'm working with an extension of JList that was written by another programmer. After your comment I took another good look into the code of that extension. Apparently he's used a custom cell renderer that I managed not to noticed the first time though.
When I dug into this code I found a line that set the background color of each cell to the same value if the user was in read only mode. I just put an if(isSelected()) around this and its working great... thanks for your help

Kris McCuller
 
Glad I helped [smile]

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top