File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing the background color on JList's
 
Similar Threads
change the border color
html form controls
Defining Highlight color of Selected Index
need JTextField that change color when focused
how to create tablespace in java dbms