1
A
回答
3
因为你没有说过你在何时,在哪里以及如何设置复合尺寸,所以我假设你正在设置一个事件的大小,以及setSize
适合我。
我在Win7,eclipse 4.2和JDK 1.6_b30上。参见示例代码:
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class Test
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
TabFolder folder = new TabFolder(shell, SWT.TOP);
folder.setLayout(new GridLayout());
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabItem item = new TabItem(folder, SWT.NONE);
item.setText("Tab 1");
final Composite composite = new Composite(folder, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Text text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text.setText("Tab 1");
Button b = new Button(composite, SWT.PUSH);
b.setText("Press");
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
composite.setSize(23, 43);
}
});
item.setControl(composite);
shell.setSize(300, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Before Pressing the Button
After Pressing the Button
虽然有赶上!只要您调整应用程序的大小,复合材料就会回到的原始尺寸!
也有 可能是一个问题,如果你不使用设置大小的任何事件(可能在SWT标签文件夹了一些bug或功能)。非侵入性的
hack
(不需要任何用户交互)是使用
PaintListener
。请参见下面的代码:
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class Test
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
final TabFolder folder = new TabFolder(shell, SWT.TOP);
folder.setLayout(new GridLayout());
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabItem item = new TabItem(folder, SWT.NONE);
item.setText("Tab 1");
final Composite composite = new Composite(folder, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Text text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text.setText("Tab 1");
folder.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
composite.setSize(23, 43);
}
});
item.setControl(composite);
shell.setSize(300, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
的PaintListener
解决方案是不是一个非常优雅的解决方案,但它适合我的发展环境。
相关问题
- 1. SWT的JFace:SelectionProvider在TabFolder中
- 2. SWT TabFolder懒加载
- 3. SWT Composite Transform
- 4. 在SWT中获取活动标签TabFolder
- 5. 如何在TabFolder中嵌入SWT TableViewer?
- 6. 将TabFolder大小内容的ScrolledCompsite设置为零
- 7. SWT TabFolder垂直方向
- 8. SWT Composite出现在右边
- 9. SWT - 你如何重新设置一个位于另一个复合材料内的Composite的大小/设置大小?
- 10. SWT Composite需要3.6.1中的包()
- 11. 在SWT中设置颜色
- 12. SWT TabFolder有什么替代方案?
- 13. 设置Java SWT shell窗口内部区域的大小
- 14. SWT设置外壳大小以跨越多个显示器
- 15. SWT - 如何更改TabFolder中现有TabItem的顺序
- 16. 如何在树中设置treeItems的最大级别(SWT)?
- 17. 更改SWT中的字体大小
- 18. 在JToolbar中设置JLabel的大小
- 19. 设置JTextField在JTable中的大小
- 20. 在ListView中设置文本的大小
- 21. SWT调整大小错误
- 22. 设置大小UIImageView
- 23. 设置UIImageView大小?
- 24. 如何设置焦点SWT TableItem
- 25. 如何在行中设置SWT列表的高度?
- 26. 设置SharedObject最大大小
- 27. Android,在TableLayout中设置列大小
- 28. 在gridLayout中设置JButton大小
- 29. 在OSMF中设置视频大小
- 30. 在vosao中设置图像大小