Java StyledText可见行数
我想知道StyledText实际显示了多少行。有可能吗 谢谢。请尝试以下代码:Java StyledText可见行数,java,swt,Java,Swt,我想知道StyledText实际显示了多少行。有可能吗 谢谢。请尝试以下代码: // 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) visib
// 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;
请尝试以下代码:
// 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;
成功了!我也找到了另一种方法,但你的更好。getBounds().height/(getLinePixel(2)-getLinePixel(1)成功了!我还找到了另一种方法,但你的更好。getBounds().height/(getLinePixel(2)-getLinePixel(1)