JNotepad Sample

This sample is located in \Samples\afc11\JNotepad.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

JNotepad is a full-featured text editor, a cross between Microsoft® Windows® Notepad and WordPad. JNotepad offers several advantages over Notepad and similar text editors: 

JNotepad is extensible and reusable. Many classes in JNotepad can be easily copied and used in your own applications. The \Samples\afc11\JNotepad\docs directory contains additional information on JNotepad:

Using the Sample

To compile the sample

  1. Run the makefile in the \Samples\afc11\JNotepad\src directory.

  2. Run Buildexe.bat in the \Samples\afc11\JNotepad\Classes directory to build the Microsoft® Win32® executable.

To run the sample

Run Jnotepad.exe in the \Samples\afc11\JNotepad\Classes directory.

You can also run JNotepad with the jview utility. Use the following command from the \Samples\afc11\JNotepad\Classes directory:

jview JNotePad

Key Project Files

JNotePad.java

This class is the main entry point of the program; it creates an instance of the JNotepad application object and runs it in the same way the system runs an applet.

JNotePadFrame.java

This class implements a frame window, fills the frame with all the controls needed, and handles the exit command.

JNoteMenubar.java

This class defines the menu bar. The class extends UIBand with additional features: it supports loading menus from resource files, automatically places menu items in a hash table for easy access, and supports a Most Recently Used Files menu. JNoteMenubar uses the ICommandFeedback.java interface to enable and disable menu items as well as to check and uncheck them.

JNoteToolbar.java

This class defines the toolbar. It operates on objects that implement the IFileOperationTarget.java interface, which contains common file operations. JNoteToolbar also implements application settings changes.

TabFileViewer.java, FeatureTabFileViewer.java, and JNoteTabFileViewer.java

These three classes descend from one another and together define the tab viewer. The uppermost parent, TabFileViewer provides basic functionality. FeatureTabFileViewer extends TabFileViewer and adds support for plug-in features and a tab context menu. JNoteTabFileViewer adds JNotepad-specific functions, such as an About JNotepad dialog box and a Properties dialog box.

JNoteUIEdit.java

This class handles the entry and display of text.

JNoteCommandFeature.java

This class handles all command processing in the application.

CommandFeature.java

This class intercepts all menu commands, toolbar commands, and accelerator key commands, identifies the command, and routes them to the appropriate place. It also implements ICommandFeedback.java, which allows parts of the application to enable and disable menu items and toolbar buttons.

SettingsObject.java

This class stores settings (user-definable options) for the entire program.

ICommandFeedback.java

This interface allows user interface components to receive feedback. CommandFeature.java implements this interface and handles all command state changes.

IFileOperationTarget.java

This interface contains methods that support common file operations.

Technologies Demonstrated

AFC

© 1999 Microsoft Corporation. All rights reserved. Terms of use.