• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting colors

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I don't think that JTextArea provides such functionality.
Use JTextPane for this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic