About this tutorial
The TextEdit tutorial begins by using the Project and Application Wizards to create the project. Then it shows you how to use the visual design tools, together with source code editing, to design the UI and hook up events. It demonstrates how some things can be set up automatically in the jbInit() method using the UI Designer, while other things must be done manually in event handlers. It steps you through handling events for commonly used components and tasks, like menu items, ButtonBar, TextArea, and system events.
It also contains specific examples that show you how to
- Use the Filer dialog box to allow the user to select a file.
- Read and write text from a text file, and how to use this text with a TextArea.
- Set colors and fonts using ColorChooser and FontChooser dialogs.
- Display information in a status bar and in the window caption.
- Add code manually to handle UI events.
- Have a menu item and a button execute the same code, by putting the code in a new "helper" method that is called by both event handlers.
- Use all of the dialogs provided on JBuilder's Palette (Filer, FontChooser, ColorChooser, and Message), including setting them up, pre-loading them with values, showing them, and retrieving the results.
- Keep track of a current filename, and whether a file is dirty, and how to handle the logic of this for File|New, File|Open, File|Save, File|SaveAs, editing, and exit.
- Rework some aspects of the Wizard-generated code to customize them for your needs (button bars, menus, panels).
- Override the processWindowEvent handler of DecoratedFrame to do confirmations and data saves, and so on, during application exit, including vetoing the exit.
To see the complete source for the TextEdit sample, open the project
samples\borland\samples\tutorial\TextEdit\TextEdit.jpr
To move among the steps of this tutorial, click the forward and backward navigation buttons at the top or bottom of each step. Click the Home button to go back to the beginning of the tutorial.