Question

Sometimes I need the label for a checkbox to be to the left of the checkbox not the right so instead of using

JCheckBox checkbox = new JCheckBox("label",false);

I do:

JCheckBox checkbox = new JCheckBox("",false);
JLabel    label    = new JLabel("label");
GroupLayout.ParallelGroup vp1 = layout.createBaselineGroup(false, false);
vp1.addComponent(checkbox);
vp1.addComponent(label);

(I am using GroupLayout) but they are not vertically aligned correctly, I've also tried

 =layout.createParallelGroup(GroupLayout.Alignment.CENTER);

which doesn't look bad but still appears different to using a single checkbox and various other options, is it possible to get the same alignment ?

Was it helpful?

Solution

you may use the function setHorizontalTextPosition(int textPosition) with the int value SwingConstants.RIGHT etc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top