Putting icon in the Jtable cell

Can I put the Icon or image in the table cell.?I am Using Jtable and default model for that.Waht should be done to place the icon or image in particular cell which will be based on some condition check.thank yousumant
[252 byte] By [JTable_need_infoa] at [2007-11-26 22:34:10]
# 1
See the API doc for JTable? See the "How to Use Tables" link at the top of that? That explains how to do custom rendering. You just need to render using a JLabel with its icon set.
itchyscratchya at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 2
ok so i know that rendering and the creating label with image or iconhow can i put that created label in table.is it likeObject data[][] is my data then i should put that data[row][col] value to that label.reply m i going right?thank you
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 3
No, you've misunderstood the rendering described in the 'how to.' The renderer provides a component to render the data in that cell - the component is not the data itself. You need to implement the TableCellRenderer interface.
itchyscratchya at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 4
JTable provides a default renderer to display icons. You just need to tell the table what type of data is stored in each column so it can use the apppriate renderer. Simple example: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=604783
camickra at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 5
I also want that to be placed in header should it work fine if i do same way?I tried but problem is there so asking?
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 6

Read the [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting]Table Sorting[/url] example. An icon is placed in the header to indicate the direction of the sort. They probably use a custom renderer since the header assumes the data for the headers is a String Object.

camickra at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 7
other than that symbol can't be placed?
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 8
I also want to know thatI am using table model written by meand if I want to implement the sorter then how can make change to the that model....or how to implement that thing.I am confuse about the use of sorter as I am reading from that table sorter example
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 9
The tutorial shows you the 3 lines of code you need to add sorting to your TableModel.
camickra at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 10
Yes It'w working Do I require to copy that TableSorter.java?
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...
# 11
what about putting icon in header of JTable?other than sorting image which comes automatically.
JTable_need_infoa at 2007-7-10 11:41:51 > top of Java-index,Desktop,Core GUI APIs...