Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for jtextArea_Comments.JPG]
Screenshot of how comments look in multiple lines
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it , it doesnt work.
 
Rupi Kaur
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I called the method where the model is set and it works now. thanks a lot.
reply
    Bookmark Topic Watch Topic
  • New Topic