Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Starting TextArea from the Top

 
Mike Cutter
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a TextArea(50,80). I have wrote code to put the contents of a text file into the TextArea. Sometimes, there are over 300 lines in a file and the TextArea will scroll down to the end. Is there a way so after the file has been read, the TextArea will be at the beginning of the file (the first line of the TextArea) instead of the end?

FTPClient ftp = new FTPClient();
BufferedReader buffStream;
String inputLine;
String file;
String login = "root";
String password = "password";

ftp.connect("hostname");
ftp.login(login, password);
ftp.changeWorkingDirectory("/etc");
buffStream = new BufferedReader(new InputStreamReader(ftp.retrieveFileStream(file)));
resultFld.setText("");
while (null != (inputLine = buffStream.readLine())) {
resultFld.append(inputLine + "\n");
}
buffStream.close();
ftp.disconnect();
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
textArea.setCaretPosition(0);
 
Mike Cutter
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never knew about setCaretPosition(0)!

Thanks to your expertise, my applet works like a charm.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic