使 JFace TableViewer 与其周围的复合材料一起调整大小?
使用 WindowBuilder for Eclipse,我创建了一个 TableViewer
,并将其放置在组合中。 (TableViewer
创建一个 SWT Table
,其中插入 TableViewer
本身)。
我尝试通过将 grabExcessHorizontalSpace
和 grabVerticalSpace
设置为 true 来调整组合的大小,但是如何使表格和 TableViewer
填充合成的?
Using the WindowBuilder for Eclipse, I have created a TableViewer
which I have placed inside a composite. (The TableViewer
creates an SWT Table
, in which the TableViewer
itself is inserted).
I have tried to make the composite resizable by setting grabExcessHorizontalSpace
and grabVerticalSpace
to true, but how to I make also the table and the TableViewer
fill the composite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我现在得到了答案(非常感谢 irc.freenode.net 上 #eclipse 频道上的 rcjsuen)。
我的代码如下所示:
复合 comp = new Composite(container, SWT.NONE);
comp.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
我需要做的是,除了将grabExcessiveHorizontalSpace和grabExcessiveVerticalSpace设置为true之外(setLayoutData()函数中的参数3和4),将参数1和2设置为SWT.FILL,并使用setLayout添加一个FillLayout对象() 函数,如下所示:
I got the answer now, (Big thanks to rcjsuen on the #eclipse channel on irc.freenode.net).
The code I had looked like this:
Composite comp = new Composite(container, SWT.NONE);
comp.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
What I needed to do was, in addition to setting grabExcessiveHorizontalSpace and grabExcessiveVerticalSpace to true, (param 3 and 4 in the setLayoutData() function), to set param 1 and 2 to SWT.FILL, and also add a FillLayout object with the setLayout() function, like so:
没有代码很难判断,但从您的描述来看,您没有在
Composite
上设置布局。如果您的组合仅包含 TableViewer,请尝试添加composite.setLayout(new FillLayout());
。如果您的组合有多个子项,您将需要一种不同的布局,例如 GridLayout 或 MigLayout。然后,您还必须在表和组合的其他子项上设置layoutData。
这里是一些片段,展示了如何使用 GridLayout。要学习 MigLayout(我发现它更好),请参阅此处。
Hard to tell without code, but from your description you don't set a layout on your
Composite
. Try addingcomposite.setLayout(new FillLayout());
if your composite contains only the TableViewer.If your composite has more than one child, you'll need a different layout, like GridLayout, or MigLayout. Then you'll also have to set layoutData on your Table and the other children of your composite.
Here are some snippets, which show how to use GridLayout. To learn MigLayout, which I find way better, see here.