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 ?
您可以将函数setHorizontalTextPosition(int textPosition)
与int值SwingConstants.RIGHT
等一起使用
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.