This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatted text display.

 
Ernesto Pye
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently working on a Java IRC Client, and I wanted to know if there's a simple way to show formatted text in a scrollable object. I could feasibly parse the incoming messages and change the control codes used on IRC with HTML code to format the text, and use something like a JLabel to show the formatted text. However, I don't seem to be able to scroll through the text of a JLabel.. Is this even possible? Or is there a different object I should look into? Or maybe I need to make a custom control or something?

I'm pretty lost here, so I'd really appreciate it if someone could point me in the right direction.

Thanks in advance
 
Ryan Smith
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your best bet would be a JTextArea (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTextArea.html), which you can set scrollable in either vertical or horizontal and (non)-editable.
 
Ernesto Pye
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was looking into that, but I don't seem to be able to display formatted text with it. However, JEditorPane does let me do this. I have a question though, is it possible to just append new HTML formatted text to it? Or do I have to change all the text everytime I want to update the box?
 
Ernesto Pye
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Talk about a bump!

Any ideas? School's now off, and I'm still wondering about this.
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so many sites saying that "Editorpane will holds the latest text only".

each time when you want to add text, just append it to textarea after that read text from textarea and put it in editorpane.

like,

textarea1.append(required text);
editorpane.setText(textarea1.getText());


Hope this helps you.

All The Best.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic