This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

create a read-only string segment that acts like a character in a textarea  RSS feed

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to create a textarea that has segments of text that act like a character. By this I mean the following:
- the whole string section cannot be edited
- if the first or last characters are deleted, the whole thing is deleted
- the cursor should jump across the whole string as if it were a single character
e.g.
[Number of Fields] * 32 + 5
where the [Number of Fields] is a segment of text that cannot be edited and has the above behaviour (the rest of the string acts like normal)
I know this sounds like a lot but I'm trying to achieve the same sort of behaviour found in Microsoft Word for autotext (like toc, page numbers or date stamps).
Is this possible (an of it)? If so, any help would be greatly appreciated.
Thanks in advance,
Steve
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this would work :
add a keyListener to the textArea. Everytime a key is pressed, extract the key tht was pressed and act accordingly (e.g. if key is '>' and character to right carat is your special field, move carat to end of field).

hope this helps,
T.
 
Steve Wood
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I've had a look at the JTextPane from what you mentioned. There's a good article I found that should start me off pretty well:
http://developer.java.sun.com/developer/TechTips/1999/tt1005.html#tip1
I should be able to take it from here.
Cheers,
Steve
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!