File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set caret position to the beginning in JtextArea every time the screen is opened?

 
Rupi Kaur
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a screen with jtextfields, labels and jtextarea. The jtextarea contains comments which occupy multiple lines.
(1) I need that everytime the screen is opened, the comments already present in the jtextarea be visible from the very start, i.e. at caretposition(0).
(2) Also, every time the user leaves the comment field the comments be reset to beginning of the text. I have done this using setcaretposition(0) in focusLost() method.

Please help me implement (1). Attached is the screenshot of how my screen looks like.

Thanks.
jtextArea_Comments.JPG
Screenshot of how comments look in multiple lines
[Thumbnail for jtextArea_Comments.JPG]
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about calling the same method i.e setcaretposition(0), after the form initialization and creation completes.
 
Rupi Kaur
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it , it doesnt work.
 
Rupi Kaur
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I called the method where the model is set and it works now. thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic