StyledText可见行数

时间:2011-11-04 14:21:50

标签: java swt

我想知道StyledText实际显示了多少行。这可能吗?

感谢。

1 个答案:

答案 0 :(得分:4)

试试这段代码:

// The index of the last (possibly only partially) visible line of the widget
int bottomIndex = JFaceTextUtil.getPartialBottomIndex((StyledText)widget);
// The index of the first (possibly only partially) visible line of the widget
int topIndex = JFaceTextUtil.getPartialTopIndex((StyledText)widget);


int visibleLines = bottomIndex - topIndex;