Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JCheckbox change the text position

How do i change the position of the text in JCheckbox. I want the text to be on the left of the check box and not as default on the right. i been over the jcheckbox, jtooglebutton and jabstractButton api few times.

like image 275
Adi Mor Avatar asked Dec 14 '11 14:12

Adi Mor


1 Answers

jCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);

It's actually inherited from AbstractButton, but you can find this also for JLabels (in this case, it's relative to the icon you may use in the label).

Now this is assuming you want just a particular change on this one component. If your goal is to reverse the direction of all components in your application (for example for a right to left reading), you should probably look into component orientation, with the setComponentOrientation and applyComponentOrientation methods.

like image 133
Gnoupi Avatar answered Oct 20 '22 21:10

Gnoupi