I need to add a column to JTable ( column of JRadioButtons).I had added through a customise renderer which implements default renderer.But the problem is the other columns works fine by having alternative color for each row except radio button column.Moreover the listener is not getting fired for radio button and also I have used customise editor which implements default cell editor.Can any one clear my doubt. Thanks in advance. Arun
To have the alternative color in your new column, you must specify in your Radio Button CellRenderer that the background color needs to be whatever it needs to be.
Then for the mouse listener, have you added a mouse listener to each cell in that column in the renderer?
Can you post the code for your Renderer and Editor.
Joined: Oct 19, 2004
The color change happens for all the rows and columns except the radiobutton column.I have added the code to editor and renderer.Moreover In editor getTableCellEditorComponent doesnt got executed.what should I do. Any suggestions
Joined: May 18, 2004
Sometimes you have to set the component's background to opaque(true) that the renderer returns. But I can't really make any good guesses without the code.
Please find below code to add Radio buttons as one of the JTable's column
jTable1.getColumn("Primary Role").setCellRenderer(new RadioButtonRenderer()); - Registering renderer to the column jTable1.getColumn("Primary Role").setCellEditor(new RadioButtonEditor(new JCheckBox()) - Registering editor to the column