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.
(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 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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.