AddressBook QBeans JDO Sample Application Tour
Previous | Next
The "main" Method The AddressBookApplication.java source contains the code required to launch the application and contruct the main application frame:



The class extends QAbstractApplication, and includes a main method that is responsible simply to
  • display the splash screen
  • load the resource bundle (AddressBookApp/src/Resources.properties) containing all the applicaton settings
  • create and set the menu and tool bars
  • construct an instance of itself.  The QBeans QAbstractApplication class is responsible to construct the actual application frame according to the settings configured in the application resource bundle 
The Resource Bundle contains a great number of settings that can be configured either at design- or run- time (as in the case in this sample).  These settings include the type of the application frame (Midi or non Midi), the background images of the desktop and default background texture of the individual windows, whether icons, text or both icons and text appears on the menu items and on the toolbar buttons, the default data source name, etc.

The settings permitted in the resource bundle are more clearly described in the resource bundle itself.

An additional set of configuration files are provided that describe the data source(s) being used by the applications.  QBeans uses these files upon the first attempt of the application to access business objects in the datasource.  These properties files are located in the AddressBookApp/src/addressbook/res/datasources folder, and contain settings specific to the datasources.

Menu and toolbars are created as collection of command beans called Functions that can perform any number of duties.  For the most part in the application menus and toolbars, functions are created to construct and launch the particular views that are associated to the application.  The following code snippet adds a QActionWindowFunction that launches the PersonsView to a menu on the menu bar:

  menuEdit.add(new QActionWindowFunction("addressbook.views.PersonsView",
                                       "AddressBook",
                                        "AddressBook",
                                        "View / modify AddressBook",
                                        getImage("people_16X16.png")));


These functions dynamically load the view by its classname in this case addressbook.views.PersonsView.

Another function used to load the database is created as an inner class of the Application class and is added to the application menubar.  The innerclass is defined near the end of the file and illustrates the use of Functions in QBeans applications:

private static class LoadDataFunction extends QAbstractFunction


Previous | Next