aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Starting TextArea from the Top Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Starting TextArea from the Top" Watch "Starting TextArea from the Top" New topic
Author

Starting TextArea from the Top

Mike Cutter
Ranch Hand

Joined: Jun 09, 2002
Posts: 49
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

Joined: Jun 09, 2003
Posts: 4632
textArea.setCaretPosition(0);
Mike Cutter
Ranch Hand

Joined: Jun 09, 2002
Posts: 49
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
 
subject: Starting TextArea from the Top