doubt regarding "getTableCellEditorComponent" function....
Hi again!
This might sound like a very stupid question, but can anyone tell when is the function-
Component getTableCellEditorComponent(javax.swing.JTable jTable, java.lang.Object object, boolean b, int i, int i1);
called and what is the task of this function? While debugging i saw that it was called before the table was displayed, but couln't understand the significance of this function.....
Plz help...
Tapsi.
[453 byte] By [
Tapsi07a] at [2007-11-27 10:22:06]

# 1
How I understand it is that every cell in the table has a cell editor. This can be the same cell editor class or you can have different cell editors for different rows/columns.
If I remember correctly from when I last looked at this it gets called when you put focus into an editable cell so that you can control the input of data and restrict/format it as you desire.
Here's a nice concise example...
http://www.exampledepot.com/egs/javax.swing.table/CustEdit.html
sanxa at 2007-7-28 17:13:57 >

# 2
Thanks for replying( i dont know your name :))
I'm confused in what component the function'll return each time? eg if i'm having a column of buttons where on clicking a button a frame pops up,
then on shifting focus to the button whether "button" is returned or the "frame"?
Plz explain......
# 3
As I understand it, in a JTable you have a render component and an edit component. The render component is used to draw the cell when it does not have focus and the edit component is used when it does. Now, I think the table comes with versions of these as standard, DefaultCellEditor or something similar, but most people want to adjust or overwrite these.
Depends what you mean by returned? Are you hooking into an event and you want to know what object comes back? You could always use the "instanceof" to do different options dependant of the class (e.g. if (obj instanceof Button) ).
This forum topic has a good example of buttons that may help you...
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=715330
...and this shows the difference between the renderer and editor...
http://www.esus.com/docs/GetQuestionPage.jsp?uid=1285
sanxa at 2007-7-28 17:13:57 >
