aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Fancy Text Area Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Fancy Text Area" Watch "Fancy Text Area" New topic
Author

Fancy Text Area

Timothy Frey
Ranch Hand

Joined: Jul 22, 2006
Posts: 56
I'm in the process of writing an AIM clone and I'd like the users to be able to send stylized text to each other. Is there any library out there that includes a custom widget that does this for me already? I'd like to be able to select a block of text, then change it's color, style, etc. I don't really have a problem writing this myself but I figure a third party library exists somewhere that already has all of this functionality. I don't know what the name of the component I'm looking for is called so I'm having a hard time googling it myself. Thanks in advance.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
javax.swing.JEditorPane should give you what you want.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Timothy Frey
Ranch Hand

Joined: Jul 22, 2006
Posts: 56
Well, right now I'm using JTextPane but setting styles is not really as straightforward as I would like. I was hoping that there was a custom made control somewhere that acted like a JTextPane but already includes a toolbar to let users change colors, fonts, and styles.

Thanks for the response, though.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I see.

We have such a thing at work. If you can wait until Monday, I will look into whether I can post the code here. (If I forget about it, bump this thread.)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I'm sorry - it's too much code to post it here (in fact I'd have some trouble finding out which classes exactly you'll need).

We intend to open source it, be we aren't there yet...

If you have some more specific problems, I'd be open to help you with code snippets, though.
Timothy Frey
Ranch Hand

Joined: Jul 22, 2006
Posts: 56
OK, no problem. I hope to tackle this problem later in the week. The first question that immediately comes to mind though is how do I go about appending text to the control? I noticed that JTextArea has an append() method but JTextPane and JEditorPane don't. Right now my only idea is that I will constantly be updating the model that JEditorPane sits on (StylizedDocument, something like that?) so I will constantly be creating a new model and attaching it to the JEditorPane. Oh, by the way, I have no idea what I'm talking about!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You're right, it is not a trivial business. Can I assume that you have not yet followed the link from the API documentation to this tutorial?
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
This isn't exactly what you want, but you may want to
take a look at the StyleFrame/StyleBox examples from
http://examples.oreilly.com/jswing2/code/#ch22


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Fancy Text Area