是否可以在 Eclipse 首选项页面上使用除 GridLayout 之外的任何内容?
以下简单的首选项页面失败并出现 ClassCastException
:
@Override
protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout());
List list = new List(container, SWT.NONE);
return container;
}
相同的代码在常规 SWT 应用程序中运行良好。如果我将 FillLayout
替换为 GridLayout
,它可以工作,但这并不能让我满意。是否无法在 Eclipse 首选项页面中使用 FillLayout
或 RowLayout
?
编辑: 非常抱歉,我在准备示例时没有给予足够的重视。上面的代码确实工作得很好。在我的代码中,我返回了列表,而不是容器(!)。出于某种原因,这在正常的 SWT 中是有效的,但这确实是无稽之谈。
The following simple preference page fails with a ClassCastException
:
@Override
protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout());
List list = new List(container, SWT.NONE);
return container;
}
The same code works fine with a regular SWT application. If I replace the FillLayout
with a GridLayout
, it works, but that doesn't satisfy me. Is there no way to use a FillLayout
or RowLayout
in Eclipse preference pages?
Edit:
I'm very sorry, I did not pay enough attention when preparing the example. The above code does indeed work fine. In my code, I returned the list, not the container (!). For some reason, that worked in normal SWT, but it's really nonsense.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是可行的,也许有两个技巧,一个是尝试这个:
如果这不起作用,那么使用 GridLayout 添加第一个容器并在 FillOut 内部肯定可以工作。
无论如何,有点奇怪,我假设提供的代码会起作用,但尝试设置该布局数据。
Should be doable, maybe two tricks, one is to try this:
And if that doesn't do the trick, then adding first one container with GridLayout and inside that FillOut should definatedly work.
Bit strange anyhow, I would have assumed that code provided would have worked, but try setting that layoutdata.