Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tried to recreate the problem on my Vista machine and using the eclipse 3.6. But it worked for me.</p> <p><strong>Here is the output:</strong> </p> <p><img src="https://i.stack.imgur.com/1wxLQ.png" alt="enter image description here"></p> <p><strong>The code I have used is as follows:</strong></p> <pre><code>import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class RightAlign { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2; shell.setLayout(layout); shell.setText("Alignment Test"); String[] labelTexts = new String[]{"label 1:","Another label:","Another label with wrapped text:"}; for (String labelText : labelTexts) { Label fieldLabel = new Label(shell, SWT.RIGHT |SWT.WRAP | SWT.BORDER ); fieldLabel.setText(labelText); GridData labelGridData = new GridData(GridData.HORIZONTAL_ALIGN_END); labelGridData.widthHint = 100; fieldLabel.setLayoutData(labelGridData); Text textField = new Text(shell, SWT.BORDER); GridData textGridData = new GridData(GridData.FILL_HORIZONTAL); textGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; textGridData.widthHint = 248; textField.setLayoutData(textGridData); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } </code></pre> <p>The only thing I <strong>changed</strong> is the <code>labelGridData.widthHint</code> from <code>160</code> to <code>100</code>. The longest label was <code>&lt; 160</code> and hence was not getting wrapped. </p>
    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.
    2. VO
      singulars
      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