JTable with my own editor/renderer
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kelly_Ryan
Posted On:   Tuesday, April 17, 2001 05:38 AM

Hi, I am having some trouble with my JTable. I have a custom model that gets data from an XML document. This data is rendered and edited by the same class that extends both TableCellRenderer and TableCellEditor. In the getTableCellRendererComponent() method I set a boolean value to false and then call getTableCellEditor() passing in the appropriate parameters. This works fine..I mean my table shows the data properly. However, when I edit a cell..this is done with a double click, the isCellEditable() is called which tests if the click count is 2. If this is true the boolean value is set to true and then getTableCellEditor() is called again. This method has code in it that is only called when the boolean value is true. This code adds the value from the model to a vector.   More>>

Hi, I am having some trouble with my JTable. I have a custom model that gets data from an XML document. This data is rendered and edited by the same class that extends both TableCellRenderer and TableCellEditor. In the getTableCellRendererComponent() method I set a boolean value to false and then call getTableCellEditor() passing in the appropriate parameters. This works fine..I mean my table shows the data properly. However, when I edit a cell..this is done with a double click, the isCellEditable() is called which tests if the click count is 2. If this is true the boolean value is set to true and then getTableCellEditor() is called again. This method has code in it that is only called when the boolean value is true. This code adds the value from the model to a vector...that is it. My problem is that when editing is invoked, the cell that is being edited turns white. What I don't understand is the fact that both the renderer and editor return the same component but the editor isn't working??? When I stop editing the cell is renderered properly again. Can anyone suggest what I am doing wrong??? I am desperate for a solution...please help!

   <<Less

Re: JTable with my own editor/renderer

Posted By:   Anonymous  
Posted On:   Wednesday, April 18, 2001 08:11 PM

Hi,
The first thing that came to my mind is whether the celleditor is set to point to ur custom celleditor. Maybe u can trace thru ur code using debug and check whether ur implemented getTableCellEditor() method is actually the one being called by the table for editing. The fact that u r receiving a white cell supports this argument cos u may be getting the default celleditor which is a JLabel... hope this helps.
About | Sitemap | Contact