Search code examples
javaswinguser-interfacejradiobuttonbuttongroup

Put JRadioButtons in new rows in ButtonGroup?


Is there a way to put JRadioButtons on new lines in ButtonGroups? I don't mean 1 button on every line but for example 2 buttons on one line and 2 buttons on the next but each in the same group like this for example:

o Button one      o Button two
o Button three    o Button four

all in one group and in one panel centered.


Solution

  • You can add the radio buttons in a GridLayout or a GridBagLayout and in the sametime add JRadioButtons to a ButtonGroup as well.