Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java StyledText可见行数_Java_Swt - Fatal编程技术网

Java 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

我想知道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) 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)