I used this guide in order to make JTable that would handle radio buttons. Works fine except i need to enable a default enabled button.
there can be n rows. I’ve tried to enable it through the default table model, the Object[][], the table, and i tried enabling the button before adding it to the Object[][]. I couldn’t figure out how(if it is possible) to do it with the buttongroup.
to find the default enabled button i have to compare the button text to a string(this part works).
Not sure that I am interpreting the question correctly. You can use
JRadioButtonconstructor to set selection, for example the snippet (based on OP code sample) will set selected button “B”:You can also change selection like this:
You can also use
ButtonGroup.setSelected()method.EDIT: eliminate components from model
The model should contain data rather than components. Storing components in the model defeats the idea of renderers and editors. For more details see Editors and Renderers and Swing Models and Renderers. Check out the following example the mimics button group behavior in the model: