Link to home
Start Free TrialLog in
Avatar of tom_corc
tom_corc

asked on

JCheckBox - align text on left

I have a JCheckbox for which I want the label or caption on the left and the checkbox on the right. I have tried using the setAlignmentX, setHorizontalAlignment and setHorizontalTextPosition methods but they don't seem to work. Does anyone have any sample code for this ?
Avatar of kylar
kylar

I don't think there is an easy way to do this, unfortunately. I think you would have to write your own Checkbox UI. You could probably fake it like this:

JPanel checkBoxPanel = new JPanel(new GridLayout(1,2));

JCheckBox myCheck = new JCheckBox();

checkBoxPanel.add(new JLabel("My CheckBoxText"));
checkBoxPanel.add(myCheck);

Sorry I couldn't be more help

Kylar
ASKER CERTIFIED SOLUTION
Avatar of jadrek85
jadrek85

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tom_corc

ASKER

That worked - Thanks