Group Widget overlaps embedded Items [message #451690] |
Sat, 05 March 2005 19:16 |
Tariq Khalaf Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hello,
I'm encountering a strange problem when drawing a group widget and trying to
include/embed other widgets on, those widgets do not display. Why ??
Here is a code sample:
------------------------------------------------------------ ------------------------------------------------------------ -------------------------------
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* @author admin
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class testGroup1
{
private static boolean internalCall;
public static void main(String[] argc)
{
Display display = new Display();
Shell shell = new Shell(display);
internalCall = true;
GridLayout layout = new GridLayout(3, false);
layout.makeColumnsEqualWidth = true;
layout.marginHeight = 10;
layout.marginWidth = 10;
shell.setLayout(layout);
Label lblName = new Label(shell, SWT.NONE);
lblName.setText("Name");
GridData grid1 = new GridData();
grid1.horizontalSpan = 1;
lblName.setLayoutData(grid1);
Text text = new Text(shell, SWT.BORDER);
GridData grid2 = new GridData(GridData.FILL_HORIZONTAL);
grid2.horizontalSpan = 2;
text.setLayoutData(grid2);
Group group = new Group(shell, SWT.SHELL_TRIM);
group.setText("Group 1");
GridData grid3 = new GridData(GridData.FILL_BOTH);
grid3.horizontalSpan = 3;
group.setLayoutData(grid3);
//----------------------------------------------------------
// Next two controls (widgets) are not appearing. Why ??
//----------------------------------------------------------
Label one = new Label(group, SWT.LEFT);
one.setText("Name");
Text two = new Text(group, SWT.BORDER);
shell.setSize(400, 400);
shell.pack();
shell.open();
while(!shell.isDisposed()){
if(display.readAndDispatch())
display.sleep();
}
if(internalCall) display.dispose();
}
}
|
|
|
Re: Group Widget overlaps embedded Items [message #451701 is a reply to message #451690] |
Sun, 06 March 2005 06:09 |
Muhammad Aamir Messages: 48 Registered: July 2009 |
Member |
|
|
You didn't set a layout on your group:
Group group = new Group(shell, SWT.SHELL_TRIM);
group.setText("Group 1");
GridData grid3 = new GridData(GridData.FILL_BOTH);
grid3.horizontalSpan = 3;
group.setLayoutData(grid3);
group.setLayout(new anyLayout());
......
"Tariq A.Khalaf" <tariqkhalaf@yahoo.com> wrote in message
news:d0d0ia$cd$1@www.eclipse.org...
> Hello,
>
> I'm encountering a strange problem when drawing a group widget and trying
to
> include/embed other widgets on, those widgets do not display. Why ??
> Here is a code sample:
> ------------------------------------------------------------ --------------
------------------------------------------------------------ ----------------
-
>
>
> import org.eclipse.swt.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
>
> /**
> * @author admin
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class testGroup1
> {
> private static boolean internalCall;
>
> public static void main(String[] argc)
> {
> Display display = new Display();
> Shell shell = new Shell(display);
> internalCall = true;
>
> GridLayout layout = new GridLayout(3, false);
>
> layout.makeColumnsEqualWidth = true;
> layout.marginHeight = 10;
> layout.marginWidth = 10;
> shell.setLayout(layout);
>
> Label lblName = new Label(shell, SWT.NONE);
> lblName.setText("Name");
>
> GridData grid1 = new GridData();
> grid1.horizontalSpan = 1;
> lblName.setLayoutData(grid1);
>
> Text text = new Text(shell, SWT.BORDER);
> GridData grid2 = new GridData(GridData.FILL_HORIZONTAL);
> grid2.horizontalSpan = 2;
> text.setLayoutData(grid2);
>
> Group group = new Group(shell, SWT.SHELL_TRIM);
> group.setText("Group 1");
>
> GridData grid3 = new GridData(GridData.FILL_BOTH);
> grid3.horizontalSpan = 3;
> group.setLayoutData(grid3);
>
> //----------------------------------------------------------
> // Next two controls (widgets) are not appearing. Why ??
> //----------------------------------------------------------
> Label one = new Label(group, SWT.LEFT);
> one.setText("Name");
> Text two = new Text(group, SWT.BORDER);
>
> shell.setSize(400, 400);
> shell.pack();
> shell.open();
> while(!shell.isDisposed()){
> if(display.readAndDispatch())
> display.sleep();
> }
>
> if(internalCall) display.dispose();
>
> }
>
> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02989 seconds