Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting location in getFocus() ? for text field  RSS feed

 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I've done this in other languages, I just don't know how to do it in java, I've looked all over the specs, however, the first place you go blind is in your eyes.

When entering a JTextField, if empty (empty, meaning contains only spaces) I would like the cursor to be positioned at the beggining of the field, If the field has some text in it, I would like to set the cursor at the end of the last not empty "space" character.

Could someone please point me in the right direction.

Thanks, Tom
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading this you want the cursor
at the beginning if the textfield contains only whitespace, or
at the end of the last non-whitespace character

if so, something like this

 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!