• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic