To create a button group is also a simple task. What we have to do is to create a number of buttons and assign the same ButtonGroup name to all these buttons. To demonstrate this, follow these steps:
radioButton1, radioButton2, radioButton3.
RadioButton1, RadioButton2, RadioButton3.
trueso that this button is the one initially selected.
Save your buttons and check out your frame.
Now let's come to the Size Ratio property in this context. If you want all three buttons to have the same width of one third of the panel they are laid out set their SizeRatio (X-Multiply-Divide-Ratio) property to 3 as seen in this picture.
Check your frame and see the result. You can also get to this if you change the layout of your panel to a GridLayout with 3 columns. But, for example, if you want to arrange a JLabel to two fifths width and a JTextField nearby to three fifths, this might be an easier way than to work with GridBagLayout.
Copyright © 2003 Wöhrmann Softwareentwicklung - Munich Germany