This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
Consider Paul's rocket mass heater.
 
subject: Different bg colors for JTable alternate rows - urgent
 
Similar Threads
Images in a JTable
Background Pattern for a Cell in JTable
JTable row coloring
JTable Color Change
JTable