When you want to customize a Swing text editor, the first thing you should do is plan a strategy for the kind of support that your new editor kit will provide. In the example that we’ll present in this article, we” provide the bare bones of what a programmer would need to edit code written in the Java programming language.At this level, we won’t be dealing with the overall environment of an IDE; that would be, a higher-level task. Instead, we’ll just create a plug-in that provides some basic services. By building on that foundation, we could easily create a higher-level environment. There are many directions we could go in, but for now, we’ll keep it simple by dealing primarily with syntax highlighting.
To perform the task of syntax highlighting, it might be tempting to use the styled-text support that Swing provides. But we’ll be building a source-code editor, and in terms of modeling, source code is really oriented more towards plain text than towards styled text. Furthermore, different programmers may want to view the documents using different style settings.
Also, if the syntax of a program gets too broken it can always be treated as plain text. So embedding styles in documents is not very desirable — at least not in the kind of editor we are building.
Leave a reply