Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Changing the text colour of JList items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing the text colour of JList items" Watch "Changing the text colour of JList items" New topic
Author

Changing the text colour of JList items

Rebecca Thornton
Greenhorn

Joined: Dec 20, 2001
Posts: 1
is it possible to change the text colour of only certain items in a JList, rather than every item - I want selected items to be a different colour to items that have not been selected so the user can recognise which they have already selected.
Thanks
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You'll need to make a new ListCellRenderer and do something like the following...



-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing the text colour of JList items