Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textArea

Status
Not open for further replies.

Sedai

Programmer
Mar 4, 2001
158
US
Is it possible to .append("blabla") differently coloured text to a textArea? For example to .append() one line of blue texts and another line of green.

Thanks.

Avendeval


 
(First I am assuming you are talking about a JTextArea)

To be blunt :) NO.

However, you can use a styled text compenent like JEditorPane (Plain, HTML, RTF) or JTextPane.

For what you are trying to do a JEditorPane would be easier, and you could just simple use standard HTML tags to do it. Make sure you call setContentType("text/html") to set it type to html. Then when you appeand just make sure you have the correct HTML tags with it.

I hope this helps you...

Rodney
 
I have just one more question.
Is it possible to do this with AWT, instead of Swing?
Actually I guess it's stupid to ask, let me check if there is an equivalent to the JEditorPane.
I found something like class BasicEditorPaneUI but it doesn't look too promising. Any adivce on that?
Avendeval


 
There is no component in java.awt package that can do what you need. Once Swing came out, the addition of new AWT GUI components to ended. They only continue to fix bugs with the GUI components.

Are you do a project the requires JDK 1.1, and you are not allowed to use external libraries? Swing is available as an external jar for JDK 1.1. If it is an applet you can use JApplet, and swing as well.

You may be able to find an AWT based HTML or RTF text component as a third party library. I know Infragistics ( still has there JSuite available (not cheap). It is a complete GUI Libarary availbe for AWT and Swing. They have several Editing Components they may have one that will do what you need with AWT. I do not think there are any supported 3rd party librarys for AWT left. You may want to check the open source market to see if someone has left there source code available for one. You can search to see they have any.

I hope this helps you in some way...

Rodney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top