Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jtextfield  RSS feed

 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

How can I set the caret position to where the user can enter words
in a jtextfield. Whenever the field becomes active I want to set the
caret position to the end of the string in the field.

setCaretPosition(getText().length()); -->does not work

Thanks,
Cathy.

[ July 20, 2004: Message edited by: Cathy Song ]
[ July 20, 2004: Message edited by: Cathy Song ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig. But even that does not work.



-Cathy.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig. I was setting the caret position in the wrong part of the code. When I added a focus listener and set it when the focus was gained, it worked great.

Thanks again!!

-Cathy.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!