0
Im使用SWT StyledText在窗口的一部分中向用户显示数据。在另一部分,我有一个图形,通过它我滑动鼠标指针。当我将鼠标滑过图表中的某个点时,它会突出显示StyledText区域中的相应条目。StyledText空指针
我想让我的textArea自动滚动到最新更改,所以我使用.setTopIndex()
。 要确定我需要能够看一看从改变textarea的哪些条目索引不突出于highligted,我用下面的(检查我的styleRange改变):
styledText.getStyleRangeAtOffset(offset)
到目前为止,我的程序功能正确。我的下一个检查:
styledText.getStyleRangeAtOffset(offset).isUnstyled
或
styledText.getStyleRangeAtOffset(offset).foreground
或类似的东西。这里输入了问题。当我调用其中任何一个时,我得到一个nullPointerException。
getStyleRangeAtOffset的返回值为空,也许你的偏移量是错误的 – deterministicFail
你的使用是否满足getStyleRangeAtOffset返回null的条件? http://help.eclipse.org/helios/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html#getStyleRangeAtOffset(int) – Charlie
你应该发布'getStyleRangeAtOffset '方法也是。 – Ioan