JTextArea display=new JTextArea();
JScrollPane scroll=new JScrollPane(display);display.setCaretPosition(
      display.getText().length() ); //这样,随着display中文本的增长,光标会自动移动