0

Im working with SWT StyledText to display data to the user in one part of the window. In another part I have a graph, over which I slide my mouse pointer. As I slide my mouse over a point in the graph, it highlights the corresponding entry in the StyledText Area.

I want my textArea to automatically scroll to the newest change, so I am using .setTopIndex(). To determine the index I need to be able to look at which entries in the textArea changed from not highlighted to highligted, I use the following (to check if my styleRange changed):

styledText.getStyleRangeAtOffset(offset)

So far my program functions correctly. My next check is:

styledText.getStyleRangeAtOffset(offset).isUnstyled 

or

styledText.getStyleRangeAtOffset(offset).foreground 

or something like that. Here enters the problem. When I call any of these I get a nullPointerException.

4

1 回答 1

0

感谢您提供的所有指针:) 经过一些调试后,我发现未编辑的 styleRange 为空。这解释了我一直收到的 nullPointer

于 2013-12-18T08:05:28.703 回答