加事件监听器。MouseMotionListener

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2158/2158491.xml?temp=.2953607
      

  2.   

    不是MouseMotionListener,大哥是光标,不是鼠标textArea.addCaretPosition(new CaretPosition(){
       public void caretUpdate(CaretEvent e){
         int caretPosition = e.getDot(); //== textArea.getCaretPosition();
         int  = e.getMark(); //有选择区域时的另一端,可能比getDot大,也可能小
       }
    }});
      

  3.   

    getCaretPosition
    public int getCaretPosition()Returns the position of the text insertion caret for the text component. 
    Returns:
    the position of the text insertion caret for the text component >= 0