Results 1 to 3 of 3
- 12-15-2011, 01:38 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 2
- Rep Power
- 0
model.addrow with background color
Hy ,
I have a table , in which i am adding new rows , after 6 rows with data I want to add a empty row with the background color red then another 6 rows with white background and so on
Java Code:private void populate(){ DefaultTableModel model = (DefaultTableModel) table.getModel(); int i,j; for(j=0;j<6;j++){ for(i=0;i<6;i++){ model.addRow(new Object[]{"dada","dadaddd"}); } model.addRow(new Object[]{"",""}); //<-this is the red row i want to add } }
How can i change the color of the empty row?
- 12-15-2011, 01:44 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: model.addrow with background color
Check out How to use Tables in Oracle's Tutorial. Especially the "Concepts: Editors and Renderers" section that explains how the cells aren't really components (with background colour etc).
It sounds like you could use a custom renderer which sets the background colour based on the row index.Last edited by pbrockway2; 12-15-2011 at 01:47 AM.
- 12-15-2011, 01:57 AM #3
Member
- Join Date
- Dec 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
How to change background color
By Jeffrey4u in forum Sun Java Wireless ToolkitReplies: 0Last Post: 10-22-2011, 08:32 AM -
Background color of window
By Annie George in forum NetBeansReplies: 1Last Post: 09-18-2010, 09:52 AM -
background color with jpanel
By hannerz06 in forum New To JavaReplies: 6Last Post: 03-31-2010, 03:25 AM -
Color-changing model
By higuchi in forum New To JavaReplies: 1Last Post: 03-19-2009, 07:29 AM -
window background color?
By javan00b in forum New To JavaReplies: 3Last Post: 01-29-2008, 10:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks