Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fancy Text Area

 
Timothy Frey
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.swing.JEditorPane should give you what you want.
 
Timothy Frey
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic