Advertisement
Guest User

Untitled

a guest
Feb 9th, 2012
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. //editor is jtextarea
  2.  
  3. Rectangle r = editor.getVisibleRect();
  4. Point top = new Point(r.x, r.y);
  5. Point bottom = new Point(r.x, r.y + r.height);
  6. int startRow = editor.viewToModel(top); // this is working. it shows 0 at initial, then after the line reaches the end and when the scrollbar gets displayed, it shows the numbers correctly, 1,2,3...
  7. int endRow = editor.viewToModel(bottom); // this is not working, when we type, it is taking column numbers
  8. editorLineNo.setText(" START ROW " + startRow + " END ROW" + endRow);
  9.  
  10. What is needed is, start row number and end row number from the jtextarea
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement