• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic