2011-11-04 30 views

回答

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; 
+0

它的工作!我發現了另一種方式來做到這一點,但你更好。 getBounds()。height /(getLinePixel(2) - getLinePixel(1) – aphex