Working with Desktop Database Applications

See Also

The following table outlines the basic process of creating desktop database applications.

Number One
Set up the IDE to Work With Your Database

  1. If necessary, Register the appropriate driver for your database with the IDE.
  2. Connect to the database from the IDE.

Number Two
Create a project and a GUI form

Create a new project using the Java Desktop Application template or the Java Application template.
  • If you want to create a simple master/detail application, use the Java Desktop Application template and the Database Application shell that the wizard offers. After completing this wizard, you will have a running CRUD (create, read, update, delete) database application based on a single database table.
  • If your application or database is more complex and you need to create the design from scratch, use the Java Desktop Application template and the Basic Application shell that the wizard offers. Or create a project with the Java Application template and then create a GUI form in the project.

Number Three
Add necessary bean and entity classes

  1. Add necessary components to the form, including custom beans for which you will create bindings and any necessary converter and validator classes.
  2. Add entity classes to the project to represent the database tables with which your application will work. (Entity classes are special classes that use the Java Persistence API.) You can generate entity classes or you can write them from scratch.

    If you have created an application that is based on the Database Application shell of the Java Desktop Application template, an entity class will have been created for you. This entity class is named according to the database table that it represents.


Number Four
Bind component properties

  1. Right-click a component in the Design view of the Source Editor or in the Inspector window, and choose a target property from the Bind menu.
  2. In the Binding tab of Bind dialog box, specify the source for the binding.
  3. In the Advanced tab of Bind dialog box, specify any other customizations to the binding, if necessary. For example, some bindings require custom converters, validators, and code for handling unreadable or non-existent values from the source.

Number Five
Generate and code actions

  1. Generate skeleton action methods for UI components by right-clicking the component and choosing Set Action to open the Set Action dialog box.
  2. In the Action drop-down list, select Create New Action.
  3. Fill in details for the action, including method name, name, tool tip text, and accelerator. Optionally, you can also make the action run as a background task and do other advanced configuration.
  4. Click OK to close the dialog box.
  5. In the Source Editor, type code for the actions.

Number Six
Deploy the application

See Also
Binding Data to a Swing Component
About Java GUIs
GUI Builder Tasks: Quick Reference
Designing Java GUIs with the GUI Builder
About the Swing Application Framework
About Actions in the Swing Application Framework

Legal Notices