• 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

Building a text editor

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic