dcsimg
How do I render boolean values using JCheckBox + add an editor in JTable
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, April 19, 2001 03:46 AM

I have a JTable with two columns, one for boolean values and one for strings. I would like to render the first column with JCheckBox and add an editor for it. The table shows a list of files and by checking/unchecking the files you add/delete the files from the list. If I extend DefaultTableCellRenderer and DefaultCellEditor what methods do I need to rewrite.

Re: How do I render boolean values using JCheckBox + add an editor in JTable

Posted By:   Kelly_Ryan  
Posted On:   Thursday, April 19, 2001 05:46 AM

The main methods you need to add your code to are getTableCellRendererComponent() and getTableCellEditor(). In the renderer method you test to see if the value (which is a parameter of the method) is a string or boolean value and return either a JLabel or JCheckbox respectively. Same with the editor...in the isCellEditable() method you set up to test if the cell can be edited...for example if click count is 2 return true in the method. Then in the getTableCellEditorComponent() you test for the value again and return the appropriate component you want for the editor. Hope this helps.
About | Sitemap | Contact