a guest Feb 9th, 2012 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //editor is jtextarea
  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);
  10. What is needed is, start row number and end row number from the jtextarea
RAW Paste Data
Want to get better at Java?
Learn to code Java in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!