How to Edit Java 4E Source Files in TextPad - dummies

How to Edit Java 4E Source Files in TextPad

By Doug Lowe

You can edit Java 4E source files in TextPad. If you’ve worked with a Windows text editor before, you’ll have no trouble mastering the basics of TextPad for all your programming needs.


When you first create a file (by clicking the New button on the toolbar or by choosing File→New), TextPad treats the file as a normal text file, not as a Java program file. After you save the file (by clicking the Save button or choosing File→Save) and assign .java as the file extension, TextPad’s Java-editing features kick in.

Check out some of TextPad’s most noteworthy features for working with Java files:

  • You can’t really tell from the figure, but TextPad uses different colors to indicate the function of each word or symbol in the program. Brackets are red so that you can spot them quickly and make sure that they’re paired correctly. Keywords are blue. Comments and string literals are green. Other text, such as variable and method names, is black.

  • TextPad automatically indents whenever you type an opening bracket and then reverts to the previous indent when you type a closing bracket. This feature makes keeping your code lined up easy.

  • Line numbers display down the left edge of the editing window. You can turn these line numbers on or off by choosing View→Line Numbers.

  • To go to a particular line, press Ctrl+G to bring up the Go To dialog box. Make sure that Line is selected in the Go to What box, enter the line number in the text box, and click OK.

  • If you have more than one file open, you can switch between the files by using the Document Selector — the pane on the left side of the TextPad window (refer to the figure). If the Document Selector isn’t visible, choose View→Document Selector to summon it.

  • Another way to switch between two (or more) files is to choose View→Document Tabs. Tabs appear at the bottom of the document window, and you can click these tabs to switch documents.

  • A handy Match Bracket feature lets you pair brackets, braces, and parentheses. To use this feature, move the insertion point to a bracket, brace, or parenthesis and then press Ctrl+M. TextPad finds the matching element.

  • To search for text, press F5. In the Find dialog box, enter the text you’re looking for, and click OK. To repeat the search, press Ctrl+F.

  • To replace text, press F8.

In TextPad, a workspace is a collection of files that you work on together. Workspaces are useful for projects that involve more than just one file. When you open a workspace, TextPad opens all the files in the workspace.

To create a workspace, first open all the files that you want to include in the workspace. Then choose File→Workspace→Save As and, in the Save As dialog box, give the workspace a name. (The files that make up the workspace are saved in a single file with the .tws extension.)

To open a workspace, choose File→Workspace→Open to display the Open dialog box, select the workspace file that you previously saved, and click Open. Alternatively, you can choose the workspace from the list of recently used workspaces at the bottom of the File→Workspace submenu.

To configure TextPad to open the most recently used workspace automatically whenever you start TextPad, choose Configure→Preferences to open the Preferences dialog box, click General in the tree on the left side of the dialog box, select the Reload Last Workspace at Startup check box, and click OK to close the dialog box.