It is said that highlighting is not accurate. In fact, it is a special font (differently font) in general IDE to display the task of the school's primary semester now is to write such a C source code editor. Require key Word distinguishes and real-time error detection and text-formatted tasks. It feels like VI. I didn't have a lot of clue when I started, and I didn't have much harvest. I just knew that I had to use JeditorPane to display, but there is no relevant display in Demo (maybe I haven't seen it). Later, I suddenly started from QQ, I should use the RTF format to display the text of different colors, and then find the specification of RTF, it can be. So the basic idea is to read a source code file, tag the keywords, converted to the corresponding RTF format text, then use JeditorPane to display (VC, DEPHLI also has corresponding components to complete this task). After each text is edited, re-conversion (this is being optimized, involving a troublesome problem). How do you convert it? From the RTF format 1, convert the '/' symbol in the source code into the rtf //, to display 2, mark keywords, notes, small parentheses, braces 3, convert other special characters, including back Hard, the three steps in the left and right brace steps are very simple, there is nothing worth studying, nothing more than traversing the entire string, converting characters, maybe it is less efficient, but I do this because I think A lot of "extra" / symbols, such as / cf1 / b, such as / cf1 / b, such as / cf1 / b, such as / cf1 / b, to make a lot of judgments. The influence of specific for efficiency I didn't do a strict mathematical argument, just I found that this may affect it, so it is necessary to convert it before tag keyword. In addition, it is necessary to judge the comment at the time of the mark, and the characters inside the comment are not within the code execution section, so in the algorithm, the part is slightly ever, then the special characters inside the algorithm are not searched. So I separated the search for special characters. Moreover, in order to reduce the search size when searching for the keyword, the special character conversion is selected after the tag key is selected.