wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Setting colors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting colors" Watch "Setting colors" New topic

Setting colors

john omeara

Joined: Nov 12, 2003
Posts: 15
Hi i am having a few problems setting up colors on my text area correctly. I have set up a jtextarea and set the forground color to green. However depending on the content i want to change the text color for that paticular piece of content and not the whole jtextarea. At the moment i keep changing the color of my foregrounf but obviously that is changing the whole jtextarea color. Any one any ideas. Below id a few lines of the code where i am changing the color:
if((packet1.toString().indexOf("ARP"))!=-1){arp_count++;System.out.println("ARP " + arp_count);textarea1.setForeground(colora);}
if((packet1.toString().indexOf("ICMP"))!=-1){icmp_count++;System.out.println("ICMP" + icmp_count);textarea1.setForeground(colorb);}
thanks again for your time
Vikalp Setya

Joined: May 10, 2003
Posts: 18
I don't think that JTextArea provides such functionality.
Use JTextPane for this.

Regards,<br />vikalps
I agree. Here's the link: http://aspose.com/file-tools
subject: Setting colors
Similar Threads
Swing: Unable to bring down the size of JPanel
Text Area..please help urgent
Errors with array and JTextArea and ComboBox
JMenu text color
word wrap styled text area?