• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there an easy way to get a String from jTextArea?  RSS feed

 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I wonder if you could help me. I'm implementing a sort of IDE for Assembly language. I have a jTextArea where the asm code is input. Because i need to parse each asm instruction, i need to get the lines of code one at a time. I'm trying to use the getLineCount & offset methods from jTextArea as follows:

I am declaring BadLocation exception for the Offset methods & it is throwing lots of exceptions! Can anyone see anything that i am doing wrong, or suggest an easier way to get the asm code line by line?
Thanks in advance,
Celine
[ May 01, 2004: Message edited by: celine mcgowan ]
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To parse EOL-char-delimited 'lines', it's probably easiest to deal with the JTextArea via the interface.
Here's an excellent place to get a cut-n-past-able code example for that (ignore highlighter stuff .. unless it helps):
http://javaalmanac.com/egs/javax.swing.text/ta_EnumLines.html
 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Clio.
I got it working with the Offset variables in the end. Woo-hoo!
Cheers,
Celine
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulations!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!