Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layoutmanager-Problem: Label to big to show correctly
Layoutmanager-Problem: Label to big to show correctly [message #441022] Tue, 10 August 2004 07:36 Go to next message
Eclipse UserFriend
Originally posted by: IngolfBayer.gmx.de

Hi,

i am new to java and have a simple Form with two groups (One group left, the
second group right of it). In the second group i will display a Label-Widget
with wordbreaking. The Label is often to width to display. Why ?

Thanks!
Ingolf

Here is the source-code:

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.layout.*;
import org.eclipse.swt.*;

public class TestLayout {
private Display display;
private Shell shell;

TestLayout() {
display = new Display();
shell = new Shell(display);
shell.setText("Test Layoutmanager");
createGUI();

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();

}

private void createGUI() {

GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginHeight = 10;
gridLayout.marginWidth = 10;
shell.setLayout(gridLayout);
GridData datashell = new GridData (GridData.GRAB_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
GridData.VERTICAL_ALIGN_FILL);
shell.setLayoutData(datashell);

/* Create a group for the tree */
Group treeGroup = new Group (shell, SWT.NONE);
treeGroup.setLayout (new FillLayout (SWT.HORIZONTAL));

GridData gd1 = new GridData (GridData.GRAB_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
GridData.VERTICAL_ALIGN_FILL);
gd1.widthHint = 200;
treeGroup.setLayoutData (gd1);
treeGroup.setText ("Group 1");


/* Create a group for the text */
Group textGroup = new Group (shell, SWT.NONE);
textGroup.setLayout (new FillLayout (SWT.HORIZONTAL));
textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
GridData.VERTICAL_ALIGN_FILL));
textGroup.setText ("Group 2");


Label aLabel = new Label (textGroup, SWT.READ_ONLY | SWT.SIMPLE |
SWT.V_SCROLL);

StringBuffer p = new StringBuffer("");
p.append("This is a very little Text to test the Layout-Manager. The
wordbreak doesn't work correct");
p.append(" when the label is in the right group. Without a group it
seems ok!");
p.append(" I think the problem is that the label is to width when the
window-width is to small!");

aLabel.setText(p.toString());

}


public static void main(String[] args) {
new TestLayout();

}
}
Re: Layoutmanager-Problem: Label to big to show correctly [message #441126 is a reply to message #441022] Tue, 10 August 2004 15:29 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866

"Ingolf Bayer" <IngolfBayer@gmx.de> wrote in message
news:cf9tcq$ups$1@eclipse.org...
> Hi,
>
> i am new to java and have a simple Form with two groups (One group left,
the
> second group right of it). In the second group i will display a
Label-Widget
> with wordbreaking. The Label is often to width to display. Why ?
>
> Thanks!
> Ingolf
>
> Here is the source-code:
>
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Shell;
>
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.*;
>
> public class TestLayout {
> private Display display;
> private Shell shell;
>
> TestLayout() {
> display = new Display();
> shell = new Shell(display);
> shell.setText("Test Layoutmanager");
> createGUI();
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
>
> }
>
> private void createGUI() {
>
> GridLayout gridLayout = new GridLayout();
> gridLayout.numColumns = 2;
> gridLayout.marginHeight = 10;
> gridLayout.marginWidth = 10;
> shell.setLayout(gridLayout);
> GridData datashell = new GridData (GridData.GRAB_HORIZONTAL |
> GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
> GridData.VERTICAL_ALIGN_FILL);
> shell.setLayoutData(datashell);
>
> /* Create a group for the tree */
> Group treeGroup = new Group (shell, SWT.NONE);
> treeGroup.setLayout (new FillLayout (SWT.HORIZONTAL));
>
> GridData gd1 = new GridData (GridData.GRAB_HORIZONTAL |
> GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
> GridData.VERTICAL_ALIGN_FILL);
> gd1.widthHint = 200;
> treeGroup.setLayoutData (gd1);
> treeGroup.setText ("Group 1");
>
>
> /* Create a group for the text */
> Group textGroup = new Group (shell, SWT.NONE);
> textGroup.setLayout (new FillLayout (SWT.HORIZONTAL));
> textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
> GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL |
> GridData.VERTICAL_ALIGN_FILL));
> textGroup.setText ("Group 2");
>
>
> Label aLabel = new Label (textGroup, SWT.READ_ONLY | SWT.SIMPLE |
> SWT.V_SCROLL);
>
> StringBuffer p = new StringBuffer("");
> p.append("This is a very little Text to test the Layout-Manager. The
> wordbreak doesn't work correct");
> p.append(" when the label is in the right group. Without a group it
> seems ok!");
> p.append(" I think the problem is that the label is to width when the
> window-width is to small!");
>
> aLabel.setText(p.toString());
>
> }
>
>
> public static void main(String[] args) {
> new TestLayout();
>
> }
> }
>
>
Previous Topic:SWT.ICON and Image(Device, ImageData, ImageData) constructor
Next Topic:standAlone application
Goto Forum:
  


Current Time: Fri Sep 20 00:06:25 GMT 2024

Powered by FUDForum. Page generated in 0.03631 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top