Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getTableCellRendererComponent() in Jtable-doubt(urgent please)  RSS feed

 
cs sakthi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai all,
I have my own table model extending DefaultTableModel. I have MyTableCellRenderer extending DefaultTableCellRenderer. I am over riding the method getTableCellRendererComponent() in MyTableCellRenderer class and setting the colors for the cells.
i want to know the logic to be put in for rendering the whole row with same background color and the value to be set. i am bit confused when we should set the data and when we should set the colors for the cells.,
one more doubt is that, when this method gets called internally, could some one can explain this ??
i am checking the row value which comes as one of the parameters for getTableCellRendererComponent() method and rendering all the columns with my favourite color, but i end up with the rendering of only first two columns, i have more than ten columns, and i want some explanation from the friends who tried for rendering the colors for each row.
i will be thankfull, to all who is spending their valuable time for me...
Expecting super fast reply,
Ever Yours,
sakthi.
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you solve this yet ? I did some stuff with tableCellRenderers recently, but I'm not really sure what you are asking here.
Kate
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you solve this yet ? I did some stuff with tableCellRenderers recently, but I'm not really sure what you are asking here.
Kate
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cs,
Create a class which extends JTable. In class you can have array or hashtable to store row as key and value with Color.
In class overide the method
public TableCellRenderer getCellRenderer(int row, int col)

I hope you have created your own TableCellRenderer(e.g. ownCellRenderer).
ownCellRenderer = new ownCellRenderer()
public TableCellRenderer getCellRenderer(int row, int col){
ownCellRenderer.setBackground(tableForeground);
return (TableCellRenderer)ownCellRenderer;
}
it works for me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!