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

Find current line number in JTextField  RSS feed

 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gurus,
is there any way to find where the cursor is in textfield or in textpane ..also whether any event will fire when we move to the next line?? please help me in this issue..
Regards & Thanks,
selva.
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To find out where the cursor is, use getCaretPosition(). There is an event fired when the cursor position changes or when text is input, but I don't know of any event that fires on a line change.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
Thanks for reply.using getCaretPosition() i can find only the cursor position.My requirement is to save the data from the textpane in some format.So next time i render it, the same style should come..I am not going to save as some document.
I will be saving the text in the field of a table..
I thought of saving the text as following format
eg:
Hello this is a sample program ie..program will be bold,italic and underline, remaining text will be only bold.

The problem comes in alignment..whenever the user makes an alignment for the line in textpane i have to keep track of that too..
I do no how to proceed for this??
Please suggest me some approach or sample or some links..
Anything will be thankful in this case..
Thanks & Regards,
silva.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is a mistake happened, i had given the tags for "Hello this is a sample program" which got rendered. i will be saving with the tags attached to the text.
silva.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!