如何在父组合中对齐两个复合体,而不使用widthHint和heightHint [英] How to align two composites in a parent composite without using widthHint and heightHint
问题描述
这是我的代码如何:
Composite composite =(Composite)super.createDialogArea(parent);
复合rowComposite = new Composite(composite,SWT.NONE);
rowComposite.setLayout(new GridLayout(2,false));
GridData gd1 = new GridData(SWT.LEFT,SWT.CENTER,false,false);
gd1.widthHint = 760;
gd1.heightHint = 240;
rowComposite.setLayoutData(gd1);
复合columnComposite = new Composite(composite,SWT.NONE);
columnComposite .setLayout(new GridLayout(2,false));
GridData gd2 = new GridData(SWT.LEFT,SWT.CENTER,false,false);
gd2.widthHint = 760;
gd2.heightHint = 240;
columnComposite .setLayoutData(gd1);
这里,im使用widthHint和heightHint,不推荐整个布局,用户决定更改系统字体或分辨率。
如何使用widthhint和heightHint实现相同的wihtout。
从两个复合和更新的网格数据中移除widthHint和heightHint如下:
new GridData(SWT.FILL,SWT.FILL,true,true);
GridLayout已经处理了宽度和高度。
I want two composites(one below the other) inside a parent component.
This is how my code looks like:
Composite composite = (Composite) super.createDialogArea(parent);
Composite rowComposite = new Composite(composite, SWT.NONE);
rowComposite.setLayout(new GridLayout(2, false));
GridData gd1 = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd1.widthHint = 760;
gd1.heightHint = 240;
rowComposite.setLayoutData(gd1);
Composite columnComposite = new Composite(composite, SWT.NONE);
columnComposite .setLayout(new GridLayout(2, false));
GridData gd2 = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd2.widthHint = 760;
gd2.heightHint = 240;
columnComposite .setLayoutData(gd1);
Here, im Using "widthHint" and heightHint which is not recommended as the whole layout will be ruined when the user decides to change the system font or resolution.
How do i achieve the same wihtout using widthhint and heightHint.
Removed the widthHint and heightHint from both composites and updated grid data as: new GridData(SWT.FILL, SWT.FILL, true, true);
The GridLayout has taken care of width and height.
这篇关于如何在父组合中对齐两个复合体,而不使用widthHint和heightHint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!