|
Re: Wrap Label [message #480529 is a reply to message #480511] |
Mon, 17 August 2009 14:22 |
Remo Loetscher Messages: 18 Registered: July 2009 |
Junior Member |
|
|
Hi Chris,
Setting a RowData-Object on the label should solve your wrapping problem:
public class LabelWrapping {
LabelWrapping() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout(SWT.VERTICAL));
int width = 300, height = 150;
Group g1 = new Group(shell, SWT.NONE);
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
g1.setLayout(rowLayout);
g1.setLayoutData(new RowData(width, height));
g1.setText("Bla");
Label l1 = new Label(g1, SWT.WRAP);
l1.setLayoutData(new RowData(width - (rowLayout.marginLeft +
rowLayout.marginRight), SWT.DEFAULT));
l1.setText("~ Some long text ~ ~ Some long text ~ ~ Some long text ~ ~
Some long text ~ ~ Some long text ~ ~ Some long text ~");
shell.setSize(350, 250);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new LabelWrapping();
}
}
hth,
Remo
Chris Turner wrote:
> I Everyone,
>
> I'm trying to build a Wizard but i'm having problems with the wright
> Layout and the Label warping. I want to Show a Label in an Groupbox the
> wraps around when it reaches the end of the GroupBox. Now it only gets
> cut if it reches the end and the text is not wraped.
> Here is my code.
>
> Group g1=new Group(composite, SWT.NONE);
> g1.setLayout(new RowLayout(SWT.VERTICAL));
> g1.setLayoutData(new RowData(300,120));
> g1.setText("Bla");
> g1.setSize(300,150);
> Label l1= new Label(g1, SWT.WRAP);
> l1.setText("~ Some long text ~");
> l1.setSize(300,120);
> g1.pack();
>
> It would be nice if anybody could point out my error.
>
> Thanks in advance
> Chris
|
|
|
Powered by
FUDForum. Page generated in 0.02423 seconds