• Post Reply Bookmark Topic Watch Topic
  • New Topic

Building a text editor

 
Neil Marsden
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I'm building a simple text editor using a JEditorPane and simple I/O streams - so far, it works like a charm.
My only question is this: I have the capability to change text colour, text font, and apply attributes like bold, italic etc. without problem. Unfortunately, changing the text attributes will change ALL of the text as opposed to only the text that has been hilighted (blocked) with the mouse. I'm having trrouble changing the attributes of a selected word only rather than changing the text attributes of the entire JEditorPane.
Anyone done this before? Maybe a TextListener would work?
One more question: what approach would I take in order to save those attributes (say, green text) into a file that would remember text attributes when loaded into the editor from file?
 
Greg Brouelette
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've played with this but I honestly can't say that I've either perfected it or can even explain it. You may want to go to www.jext.org which is an open source Java based text editor and look at their source code to learn how it's done.
I remember you had to do some work with a StyledEditorKit class but it's been too long ago for me to remember any details. (The mind is the first thing to go at my age)
But maybe that can at least point you in the right direction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!