How to define JRadioButton label position?

Share:

In this code snippet you’ll see how to define JRadioButton label position. By default the label will be displayed on the right side of the button. In the code below you will see some examples for placing the label on the left side, at the top and the bottom of the JRadioButton.

To define the label position we use the combination of the setHorizontalTextPosition and setVerticalTextPosition method and specified the position using one of the available constant in SwingConstants interface.

Here is the result of the snippet:

Label Position in JRadioButton

Label Position in JRadioButton