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 Different bg colors for JTable alternate rows - urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Different bg colors for JTable alternate rows - urgent" Watch "Different bg colors for JTable alternate rows - urgent" New topic
Author

Different bg colors for JTable alternate rows - urgent

cs sakthi
Greenhorn

Joined: May 11, 2001
Posts: 15
Hi All,
Could any body help with code snippet for rendering the alternate rows background with different colors using Jtable, for eg.,
row 1 bgcolor - red
row 2 bgcolor - green
row 3 bgcolor - red
row 4 bgcolor - green and so on...
Thanx,
Ever Yours,
sakthi.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Create your own cell renderer. Extend DefaultTableCellRenderer and override the getTableCellRendererComponent() method. Check what row the cell is in and set the background color to what you want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Different bg colors for JTable alternate rows - urgent