Originally posted by Arun Bommannavar: I need to make radio buttons in one row and one column in a JTable, the rest being either Strings or data (double).
So it looks like a matrix. I wish to select either a row of data or column of data depending on the radio button selected.
Any hints, suggestions are most appreciated.
Don't put instances of JRadioButton() in your table model. Instead, put either Boolean.TRUE or Boolean.FALSE in your model, then worry about table cell renderers at a later step.
Also, don't plan on using the cell renderers (even if they look like radio buttons) to enforce the "only one on" policy. Handle this in the setValueAt() method of your table model (and be sure to call fireTableCellUpdated() or fireTableRowsUpdated() methods for any cells that change value).
As for the renderers, I recommend starting with the default renderer for Boolean, which will look like a JCheckBox, not a JRadioButton. (You can change it to a radio button renderer later, after you have things working.) You can get this for the column of buttons by simply returning Boolean.class in your table model's getColumnClass() method. Getting a single row to use the rendeder will be a bit harder, so start with the column.
I might suggest that it might be a easier to extend AbstractTableModel instead of DefaultTableModel. That way you can keep the boolean arrays and the double arrays separate, referring to them as appropriate in the getValueAt() method.