|
Re: SWT Multiline text resizing and wrapping [message #511229 is a reply to message #511216] |
Sun, 31 January 2010 10:15   |
Eclipse User |
|
|
|
I think this code can help you:
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);
Composite compos = new Composite(shell, SWT.NONE);
compos.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
GridLayout layout = new GridLayout();
compos.setLayout(layout);
final Label label = new Label(compos, SWT.WRAP);
final GridData data = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
label.setLayoutData(data);
label.setText("asda sda sdasd asda sda sdada dadads asd adsad as dadsa sad sada dsasda sd adsa sasd");
label.setBackground(display.getSystemColor(SWT.COLOR_RED));
new Button(compos, SWT.PUSH).setText("sfdsfsd");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
|
|
|
|
|
Re: SWT Multiline text resizing and wrapping [message #511455 is a reply to message #511216] |
Mon, 01 February 2010 06:10   |
Eclipse User |
|
|
|
I think this shows what you want:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Composite compos = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout();
compos.setLayout(layout);
final Label label = new Label(compos, SWT.WRAP);
GridData data = new GridData();
data.widthHint = 10; // <-- minimum width, will grow based on Button
width
data.horizontalAlignment = SWT.FILL;
label.setLayoutData(data);
label.setText("asda sda sdasd asda sda sdada dadads asd adsad as dadsa
sad sada dsasda sd adsa sasd");
new Button(compos, SWT.PUSH).setText("sfdsfsd sfdsfsd sfdsfsd sfdsfsd
sfdsfsd sfdsfsd");
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"Simon L." <abcba1307@yahoo.de> wrote in message
news:hk3pem$h42$1@build.eclipse.org...
> Hello,
> simple question I think, but can't find an answer:
>
> (GridLayout)
> I have a container with multiple controls grabbing horizontal space and
filling it. And a multiline text, which I want to fill the container
horizontally, too, but with not being responsible for the width the
container has.
> it means, that I want the multiline text to have always the width of the
container, but I dont want a long string in the text field to make the
container take more horizontal space than it would take without the text
field.
>
> Thanks in advance :)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03867 seconds