File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Setting colors

john omeara
Greenhorn

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);}
packetcount=packetcount+1;
text1.append(packet1.toString()+"\n");
thanks again for your time
Vikalp Setya
Greenhorn

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


Regards,<br />vikalps
 
jQuery in Action, 2nd edition
 
subject: Setting colors