【发布时间】:2012-12-03 20:12:34
【问题描述】:
我一定错过了一些愚蠢的东西。 docs 明确指出 RowLayout 布局的 RowData 对象允许您指定最小尺寸(宽度和高度),这是有道理的。但是,当底层小部件超过此大小时,大小不会增加并且小部件会被裁剪。真的是最低限度吗?
例子
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Example");
shell.setBounds(100, 100, 325, 200);
shell.setLayout(new FillLayout());
Composite comp = new Composite(shell, SWT.BORDER);
comp.setLayout(new RowLayout(SWT.VERTICAL));
Label label1 = new Label(comp, SWT.CENTER);
label1.setLayoutData(new RowData(20,20));
label1.setText("Trying with bounded rowdata...");
Label label2 = new Label(comp, SWT.CENTER);
label2.setText("Trying with no rowdata...");
comp.layout(true,true); // no difference
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
结果:
【问题讨论】:
-
你想在这里实现什么目标?
-
这只是一个例子。但我想要的是文档似乎暗示的内容:为布局内的小部件设置最小尺寸,使其至少获得该尺寸。