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 To set color for rows in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "To set color for rows in JTable" Watch "To set color for rows in JTable" New topic
Author

To set color for rows in JTable

Rajan
Greenhorn

Joined: Jun 19, 2001
Posts: 6
Hi all,
Can any body help me in setting different color for rows. I have done it for column.
thanks
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Rajan",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
In the DefaultCellRenderer this method
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Gives both the row and column. Check the row and do what you would have for the column.
Rajan
Greenhorn

Joined: Jun 19, 2001
Posts: 6
Hi Paul,
I have to do it dynamically. How can i pass the row index so that i can check with the getTableCellRendererComponent method's row(int).
Once after creating the table, according to certain creteria i have change the color of the corresponding row.
Can help me in this issue.
thanks
Rajan

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To set color for rows in JTable
 
Similar Threads
JTextArea Alternate Row color Change
How to Set the JTable Rows Color??
Weirdness with JSTL and Style Sheets
Color in JTable
how to solve this simple problem in jstl ?