Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Giving Different Colours for text in a JTextArea

Posted on 2007-10-12
11
Medium Priority
?
1,166 Views
Last Modified: 2013-11-23
I have a Java Swing Application. I want to give different colors for text in a JTextArea.

Thanks.
0
Comment
Question by:sangameshrh
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 672 total points
ID: 20063794
Easiest to use a JTextPane and use html markup
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20063797
0
 
LVL 92

Expert Comment

by:objects
ID: 20063812
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sangameshrh
ID: 20063881
How to append text for a JTextPane?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 664 total points
ID: 20063926
0
 
LVL 5

Assisted Solution

by:ebertk
ebertk earned 664 total points
ID: 20072755
Nice example here that compares TextArea to JTextArea to JTextPane
http://javatechniques.com/blog/setting-jtextpane-font-and-color/

Note that JTextPane is much more complete at handing what you are looking for, but it is a more complex class to deal with.  

Here is a link that shows you how to append text to a JTextPane, the example creates a class that extends JTextPane and adds a method to easily append new text.
http://www.java2s.com/Code/Java/Swing-JFC/AppendingTextPane.htm
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20073280
>>but it is a more complex class to deal with.  

Not if you use html - it's a cinch
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20439014
Forced accept.

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question