aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Changing the background color on JList's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing the background color on JList Watch "Changing the background color on JList New topic
Author

Changing the background color on JList's

Cameron Bruce
Greenhorn

Joined: Jun 12, 2003
Posts: 4
Is it possible to change the background color on a JList and display alternative colors (eg. white, yellow, white, yellow,.. etc) ??
Cameron.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You would just create a new ListCellRenderer for the list that set the color of the background of the cell based on the index. Take a look at the WhiteYellowCellRenderer inner class in the following code :



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing the background color on JList's