To test the Text Editor:
Set the path of the bin directory of J2SDK by executing the following command at the command prompt:
set path=%path%;D:\j2sdk1.4.0_02\bin;
Set the classpath of the lib directory of J2SDK by executing the following command at the command prompt:
set classpath = %classpath%;d:\j2sdk1.4.0_02\lib;
Copy the Editor.java, ActionPerform.java, ColorClass.java, FontClass.java, PrintClass.java, and Help.java files to a folder on your computer. Compile the files using the following javac command:
javac *.java
To run the Text Editor, specify the following command at the command prompt:
java Editor
Select the File->New command from the menu bar. A new text file is opened in the Text Editor, as shown in Figure 6-7:
Figure 6-7: The Untitled Text Editor Window
Write Hello, this is a sample file, in the currently untitled text file.
Select the File->Save As command from the menu bar to save the file. A Save As dialog box appears, as shown in Figure 6-8:
Figure 6-8: Save As Dialog Box
In the Save As dialog box, specify the file name as Test and location as C:\CodeBook.
Select the File->New command from the menu bar to clear the text area.
Select the File->Open command from the menu bar to open the file, Test.txt. The Open dialog box appears, as shown in Figure 6-9:
Figure 6-9: Open Dialog Box
Click the Open button of the Open dialog box that opens the Test.txt file from C:\CodeBook in the Text Editor, as shown in Figure 6-10:
Figure 6-10: Displaying the Test.txt File
Select the Format->Font command from the menu bar to open the Font dialog box, as shown in Figure 6-4. Specify the font as Verdana, size as 20, and style as Italic. Click the OK button to apply the font changes to the file, as shown in Figure 6-11:
Figure 6-11: Displaying the Test.txt File with Selected Font
Select the Format->Color command from the menu bar to open the Color dialog box, as shown in Figure 6-10. Specify the RGB values in this dialog box and click OK. The color of the file is modified, as shown in Figure 6-12:
Figure 6-12: Displaying the Test.txt File with Selected Color
Select the Lock->Exclusive Lock command from the menu bar. This locks the Test.txt file.
Select the Start->Programs->Accessories->Notepad command to open a Windows notepad utility.
Select the File->Open command from the menu bar of the Notepad utility. Open the Text.txt file from the C:\CodeBook location.
Change the contents of the file and select the File->Save command from the menu bar. An error message appears because the file is locked, as shown in Figure 6-13:
Figure 6-13: Displaying Error Message