File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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:
subject: Setting colors
jQuery in Action, 3rd edition