File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

color Java text

 
sara rod
Greenhorn
Posts: 23
  • 0
  • 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,
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • 0
  • 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
  • 0
  • 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
 
Paul Clapham
Sheriff
Pie
Posts: 20208
26
MySQL Database
  • 0
  • 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.
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic