SWT Composite构造函数对非null参数抛出IllegalArgumentException

时间:2010-05-18 06:13:32

标签: java scala swt

这段代码(在Scala中)

val contents = {
  assert(mainWindow.detailsPane != null)
  new Composite(mainWindow.detailsPane, SWT.NONE)
}

抛出异常:

Exception occurred
java.lang.IllegalArgumentException: Argument not valid
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.widgets.Widget.error(Unknown Source)
    at org.eclipse.swt.widgets.Widget.checkParent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Control.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Scrollable.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Composite.<init>(Unknown Source)
    at main.scala.NodeViewPresenter$NodeViewImpl.<init>(NodeViewPresenter.scala:41)

根据documentationIllegalArgumentException只应在父级为null时抛出,但我正在检查它。 detailsPaneCTabFolder。为什么会发生这种情况?

2 个答案:

答案 0 :(得分:2)

给出at the Eclipse forums的解决方案:detailsPane原来被处理掉了。

答案 1 :(得分:1)

您是否检查过小部件是否已被处理?

编辑:没有看到你回答;)