TextEdit Beans
Back to the TextEdit Page.
Last Updated 9/29/97
JavaBean support
TextEdit may be extended by JavaBean plug-ins. These beans appear in the editor's "Options" menu.
The standard distribution includes samples of these beans (source code for these beans may be
found in the "src" folder).
JavaBeans, as specified by JavaSoft, may vary considerably in complexity. The beans used in
this editor are on the very simple end of the scale. Two Java class interfaces are provided.
Edit beans which implement these interfaces are dynamiclly loaded by the edtior at start-up.
The member functions required by the editor are defined by these interfaces, so no further
class introspection is needed.
The interfaces are very simple, containing just two methods:
- getMenuString - returns a string which is added to the Options menu.
- filterText - processes text from the editor.
The way it works
- The editor searches its "jars" folder and loads all beans on start-up.
- The editor calls the bean's getMenuString method and inserts the result in the "Options" menu.
- When the user selects a bean from the "Options" menu, the editor calls that bean's filterText
method. The filterText method is passed a String containing any currenly selected text from the
editor. If no text is selected an empty String is passed. The filterText method returns a new
String containing updated text. (A null pointer may be returned to cancel the operation.)
- The editor then deletes any selected text and inserts the String provided by the bean.
More Information:
Please drop me a line if you have any questions.