ta.setCaretPostion()将会激发你所讲的事件

解决方案 »

  1.   

    javax.swing.event 
    Interface CaretListener
    All Superinterfaces: 
    EventListener 
    All Known Implementing Classes: 
    JTextComponent.AccessibleJTextComponent --------------------------------------------------------------------------------public interface CaretListener
    extends EventListener
    Listener for changes in the caret position of a text component. 
    --------------------------------------------------------------------------------Method Summary 
     void caretUpdate(CaretEvent e) 
              Called when the caret position is updated. 
      Method Detail 
    caretUpdate
    public void caretUpdate(CaretEvent e)
    Called when the caret position is updated. Parameters:
    e - the caret event
      

  2.   

    当在一个记事本中敲入字符时,依次发生的是
    KeyPressed,KeyTyped,KeyReleased.其中有
    CaretUpdate(有CaretListener产生)事件,不知
    在那一时间发生,    
             ta=new JTextArea();
        ta.setWrapStyleWord(true);
        ta.addCaretListener(this);
        ta.addKeyListener(this);
    那位英雄能给我解释一下,谢谢!!!!
    public interface CaretListener
    extends EventListener
    Listener for changes in the caret position of a text component. 
    --------------------------------------------------------------------------------Method Summary 
     void caretUpdate(CaretEvent e) 
              Called when the caret position is updated.