Note that there are some explanatory texts on larger screens.

plurals
  1. POSimultaneously right-align and wrap text in an SWT label in Linux/Gnome
    primarykey
    data
    text
    <p>I have a problem which appears when using Ubuntu Linux/Gnome, but seemingly not on Windows (as seen in one of the answers), that I can't use <code>SWT.RIGHT | SWT.WRAP</code> together, when creating a new label, in order to both make the text right-aligned and wrappable.</p> <p>Background:</p> <p>I'm using a simple 2-column Grid layout in a wizard, to create a dynamic number of rows with one label and one textfield per row. I want the labels to be of fixed size and with the text inside it right-aligned, like so:</p> <pre><code> label 1: [Text field 1] Another label: [Text field 2] Another label with wrapped [Text field 3] text: </code></pre> <p>The gridlayout is created like so:</p> <pre><code>GridLayout gl = new GridLayout(); gl.numColumns = 2; composite.setLayout(gl); </code></pre> <p>and this is how I try to create the rows (with one label and one textfield per row):</p> <pre><code>for (String labelText : labelTexts) { Label fieldLabel = new Label(this.composite, SWT.RIGHT | SWT.WRAP | SWT.BORDER ); fieldLabel.setText(labelText); GridData labelGridData = new GridData(GridData.HORIZONTAL_ALIGN_END); labelGridData.widthHint = 160; fieldLabel.setLayoutData(labelGridData); Text textField = new Text(this.composite, SWT.BORDER); GridData textGridData = new GridData(GridData.FILL_HORIZONTAL); textGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; textGridData.widthHint = 248; textField.setLayoutData(textGridData); } </code></pre> <p>The problem is this part: <code>SWT.RIGHT | SWT.WRAP</code> above, since it does not work to use them both simultaneously. So how can I get around that, and both right-align the text in the labels, and make the text wrap?</p>
    singulars
    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.
 

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