应该说光标比较确切.
addCaretListener(CaretListener listener)
你应会用接口的吧.

解决方案 »

  1.   

    biti_9512207(波波斯基)
    请给个简单的完整的例子
      

  2.   

    biti_9512207(波波斯基)
    请给个简单的完整的例子   
      

  3.   

    刚好看到个例子,copy给你吧.
    CaretListenerLabel caretListenerLabel =
        new CaretListenerLabel("Caret Status");
    ...
    text.addActionListener(caretListenerLabel);
    ...
    protected class CaretListenerLabel extends JLabel
                                       implements CaretListener
    {
        ...
        public void caretUpdate(CaretEvent e) {
            //Get the location in the text
            int dot = e.getDot();
            int  = e.getMark();
    ...
        }
    }
    -----------------------
    The CaretEvent class defines two useful methods: int getDot() 
    Returns the current location of the caret. If text is selected, the caret s one end of the selection. 
    int getMark() 
    Returns the other end of the selection. If nothing is selected, the value returned by this method is equal to the value returned by getDot. Note that the dot is not guaranteed to be less than the .