SHARE
TWEET

Untitled

a guest Feb 9th, 2012 105 Never
  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
RAW Paste Data
Top