Application Client
Sometimes, enterprise applications use a stand-alone client application for handling tasks such as system or application administration. For example, the Duke's Bank application uses an application client to administer customers and accounts. This capability is useful in the event that the site becomes inaccessible for any reason or if a customer prefers to communicate things such as changes to account information by phone.
The application client shown in Figure 38-3 handles basic customer and account administration for the banking application through a Swing user interface. The bank administrator can perform any of the following functions on the respective tabs.
Figure 38-3 Application Client
Customer Info tab:
Account administration:
Error and informational messages appear in the bottom under
Messages
.The Classes and Their Relationships
The source code for the application client is in the
<
INSTALL
>/javaeetutorial5/examples/dukesbank/dukesbank-appclient/src/java/com/sun/tutorial/javaee/dukesbank/client/
directory. The application client is consists of a single class:BankAdmin
.BankAdmin Class
The
BankAdmin
class, which creates the user interface, is a Swing class that provides action methods that are called when certain events occur in the application, and methods that call the controller session beans. It was created using the NetBeans 5.5 Swing editor, Matisse.
Note: Although
BankAdmin
was written using NetBeans 5.5, you do not need to have NetBeans installed in order to run the application. If you want to alter the user interface, however, you do need to use NetBeans.
Constructor
The
BankAdmin
constructor creates the initial user interface, which consists of a menu bar, two tabs, and a message pane, by calling theinitComponents
method. The menu bar contains the standard File and Edit menus, the left tab is for viewing and updating customer information, the right tab is for viewing and updating account information, and the messsage pane contains a message area.The
initComponents
method is automatically generated by NetBeans. It creates all the user interface elements visible inBankAdmin
.Class Methods
The
BankAdmin
class provides methods that other objects call when they need to update the user interface. These methods are as follows:
setCustomerTextFields
: When true enables the user to enter or change information in the customer tab. When false, the fields are disabled.fillCustomerTextFields
: Uses aCustomerDetails
object to display customer information in the customer tabclearCustomerTextFields
: Clears the contents of the customer fields in the customer tabsetAccountTextFields
: When true enables the user to enter or change information in the account tab. When false, the fields are disabled.fillAccountTextFields
: Uses anAccountDetails
object to display account information in the account tabclearAccountTextFields
: Clears the contents of the account fields in the account tabresetAll
: CallssetCustomerTextFields
andsetAccountFields
, setting all the fields to disabledThe following methods interact with the controller session beans to create and update customer and account information:
The
<
UI Element
>MouseReleased
methods are linked to the GUI controls inBankAdmin
. They call the previous methods to enable/disable the GUI fields, and create/update accounts and customers.