• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Starting TextArea from the Top

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
textArea.setCaretPosition(0);
 
Mike Cutter
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I never knew about setCaretPosition(0)!

Thanks to your expertise, my applet works like a charm.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic