• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

color Java text

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have to show text as java text. I mean, to open file in an editor pane and to color the special words (like, highlight the key words (import, private, etc.) with the same color...)
as a result I want to show the file as it is ahown in other editors of java(eclipse, netBeans, etc..)
Does anybody know code that do this thing?
It will be great if someone know and can give it to me.
thank you all,
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You could convert your text into html and use this:


 
sara rod
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

this is how to color any text.

the question is how do i know its a java text? how can i know it is public / private - to color it in one color, how do i know its a comment - to color it in a different color etc.

thanks
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean like there's different colours in the code examples posted here? You need some code which tokenizes and parses a string as if it were Java. That code would have to understand the basic syntax of Java for a start.
 
Rancher
Posts: 3191
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the question is how do i know its a java text? how can i know it is public / private - to color it in one color, how do i know its a comment - to color it in a different color etc.



Well, its not easy. You need to parse the text and reset the attributes every time the text is changed.

You can search the web using "syntax highlighting" and you might find some suggestions.
 
    Bookmark Topic Watch Topic
  • New Topic