Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you use GroupLayout, the Netbeans GUI builder can align the text of a check box and a label on the next line.... sort of.</p> <p>It appears to work well for Nimbus, but in the other LAF the label text is one pixel too far to the right. Looking at the generated code for the GroupLayout in the GUI builder, it makes a gap of 22x22 in front of the label. For Nimbus, 22 seems right, but for the other LAFs it appears to be 21.</p> <p>The generated code looks like this.</p> <pre><code>GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHortizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(22,22,22) .addComponent(label) ) .addComponent(checkBox) ) ) ); layout.setVerticalGroup( layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(checkBox) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(label) ) ); </code></pre> <p>This code would go in the constructor of the sample class after the assignments of label and checkBox. Also, remove the setLayout(null);</p> <p>All of this being said, based on what I've seen using the GUI builder, I'd recommend the following for real:</p> <ol> <li>remove the <code>Border cbBorder</code> bit from the sample</li> <li>add the <code>checkBox.getIconTextGap()</code> to the labelX.</li> <li>If the LAF is nimbus, then add 4 to labelX. :) </li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload