Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

set the cursor back to top in a TextArea

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get my cursor back to the top of the JTextArea after i hit enter to send the text over the connection.

it returns to the next line after i hit enter, then i try and set the caret position = to 0, but that only affect that line. how do i make it to where even though im hitting enter, right after that, it clears the text and makes the cursor go back to the first line?

Thanks,

Justin Fox
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let's swing this over to the intermediate forum...
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Robot right now, and using it to press backspace right after i hit the enter key, to get it back to the initial position.

Is there a better way?

This seems to be working just fine, but i could've swore I used a different way before.

Thanks,

Justin Fox
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried setText("")?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this question is about Swing and we have a Swing forum, I'm going to move this thread to it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic