what is the way or logic to make code like java Editors do, the make keywords red and other statements black, i want to make the java code for it.any help will be appreciable.
Asked
Active
Viewed 99 times
-1
-
i had tried JTextPane, but failed – HelpMe Jul 04 '13 at 10:16
-
(1) Recognize the keywords, and (2) colour them. (2) is the easy part. – user207421 Jul 04 '13 at 10:41
-
I guess the first step in the whole process starts with understanding [Regular Expressions](http://docs.oracle.com/javase/tutorial/essential/regex/) in a good way. Depending on the string literals, you colour them against their category. – nIcE cOw Jul 04 '13 at 11:02
-
possible duplicate of [Syntax Highlighting: How Does Eclipse Do It So Fast?](http://stackoverflow.com/questions/7243409/syntax-highlighting-how-does-eclipse-do-it-so-fast) – Puce Jul 04 '13 at 11:25
-
as the above link conveyed me something, which in turn tells that it is not that much easy as i was thinking, I am still got fumbled while studying AST, but thank you for your answer friend. – HelpMe Jul 05 '13 at 11:20
3 Answers
1
Use JEditorPane
. This is excellent tools to make your keyword color as well as HTML tags.

Masudul
- 21,823
- 5
- 43
- 58
1
You need a component which shows HTML string. Some strings, which you consider "java keywords" are taking "blue keyword css style" and others ( static variables) bold style and so on. A long ways to do it, start with an open-source IDE and see it.