wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to set caret position to the beginning in JtextArea every time the screen is opened? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set caret position to the beginning in JtextArea every time the screen is opened?" Watch "How to set caret position to the beginning in JtextArea every time the screen is opened?" New topic
Author

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

Rupi Kaur
Greenhorn

Joined: Mar 19, 2009
Posts: 20
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.



[Thumbnail for jtextArea_Comments.JPG]

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

How about calling the same method i.e setcaretposition(0), after the form initialization and creation completes.


Swastik
Rupi Kaur
Greenhorn

Joined: Mar 19, 2009
Posts: 20
I tried it , it doesnt work.
Rupi Kaur
Greenhorn

Joined: Mar 19, 2009
Posts: 20
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
 
subject: How to set caret position to the beginning in JtextArea every time the screen is opened?
 
Similar Threads
JTextArea and GridBagLayout ??
Converting a two dimensional int array into a byte array
Putting numbers into array
Can two browsers share Session object
tracking seconds