Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem synchronizing JTextAreas  RSS feed

 
naresh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using 2 JTextAreas in my program which are synchronized. In my program I send a string of variable length to server and receive a response of variable length. I'm appending the request and response to the textareas. I expect the textareas to show the request and only the respective response when i scroll. For this i'm trying to set the length of the caret positon of both the textareas to the maximum length string ,among request and response while appending. but the text area with smaller string is throwing an exception stating that it could not set the caret position at that length. In need to resolve this problem. Alternative solutions are accepted. Thanks in advance
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Neo",
Welcome to the Ranch, we are happy to have you here

On you way in you seem to have missed out on our naming policy, which states that your display name should contain a first and last name, and should not be obviously fictitious.
You can adjust your display name by clicking here.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the request and response strings differ in length, you will have to maintain the "offset" record for these Strings.
If the user scrolls the request text area, lookup the offset for the corresponding response and set the caret position accordingly and vice versa.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!