|
Re: SWT Multiline text resizing and wrapping [message #511229 is a reply to message #511216] |
Sun, 31 January 2010 15:15 |
|
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 #511282 is a reply to message #511257] |
Mon, 01 February 2010 05:16 |
|
Hi, As I can't see the full scene of you code(I mean those parent composites). So I just assume the parent container is Shell.
And somewhat,I do think there is a bug or bad implement of swt Label control.
So those code just for your reference.
try this code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class TestMain {
/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(400, 400);
Button button2;
Text text1;
Composite composite3 = new Composite(shell, SWT.NONE);
GridLayout composite3Layout = new GridLayout();
composite3.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
composite3.setLayout(composite3Layout);
composite3Layout.makeColumnsEqualWidth = true;
button2 = new Button(composite3, SWT.PUSH | SWT.CENTER);
GridData button2LData = new GridData();
button2LData.widthHint = 161;
button2LData.heightHint = 25;
button2.setLayoutData(button2LData);
button2.setText("button2");
text1 = new Text(composite3, SWT.MULTI | SWT.WRAP | SWT.TRANSPARENT);
GridData text1LData = new GridData();
text1LData.horizontalAlignment = GridData.FILL;
text1LData.grabExcessHorizontalSpace = true;
text1LData.widthHint = 161;
text1.setLayoutData(text1LData);
text1.setText("Find the right blocklength and try to move the columns to find the plaintext.");
text1.setEditable(false);
composite3.pack();
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 11:10 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
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.04077 seconds