> List of tutorials for developing a Fat-Client in Java

Index – Advanced Java-Fat-Client development

Mandatory steps for developing a Task-Frame –
Step-by-step-guide for Java-Fat-Client development

* For this document and all references (links) please obey the hints and regulations concerning copyright, disclaimer and trademarks.

  • The owner of this web-site (www.javascout.biz) is not responsible for the content of web-sites linked within this document or other documents of www.javascout.biz.

  • If this document or other documents of this web-site (www.javascout.biz) infringes your rights or you think that rights of others (third parties) are infringed, please inform the author.
    An e-mail can be sent by clicking onto the 'hungry mailbox' in the upper right corner.

Last revision of this document:
2006-08-30

This document lists the steps (with links to more detailed descriptions and sample code) to develop a Start-Frame as Command-Center to start Task-Frames to perform Business-Tasks.

Shortcut:

This document covers the following steps:

Credits:

To many to list; please see the linked documents with the detailed descriptions.

Prerequisites:

Step by step instructions:

Create the class

A more detailed description with screenshots is in the document JS_FC01i – Create and code the class for the 'Task-Frame' to maintain 'Projects'.

In catchwords:
Right click onto the 'Project' and select >New>Other...
In the following window expand 'Java' (if not alredy done), select >Visual Class and click the [ Next > ] button.
Enter the Package (xxx_project_xxx.clientframes, e.g. js_projassist.clientframe),
   the (Class-)Name (XXX_Project_XXX_BusinessTask, e.g. JS_ProjAssist_Project) and
   the Superclass (js_base.frame.JSBS_TaskFrame).
   Make sure that no checkbox is marked and click the [ Finish ] button
.

As the constructor of the inherited class has a parameter, an error is reported as soon as the class is created.
This error will be fixed in the next step.

top.

Code the 'Constructor' and call the class from the 'CommandCenter'

The following step assumes, that the GUI-elements of the standard layout (as defined in the inherited class JSBS_TaskFrame) should be used.

To keep the code clearly arranged, the constructor just calls three methods with the consecutive commands.
The parameter passed (language used during start-up) will be used in one of the following steps.
public class JS_ProjAssist_Project extends JSBS_TaskFrame {
/*
 * -------------------------------
 * Constructor of the class */
    public JS_ProjAssist_Project(JSBS_StartFrame parmCC){
      super(parmCC);
      initialize_before_frame();
      initialize_frame();
      initialize_after_frame();
    }

 
/*
 * -------------------------------
 * Method with code to be executed before the GUI is build */
    private void initialize_before_frame() {
    }
 
/*
 * -------------------------------
 * Method with code to construct and display the GUI (Graphic User Interface) */
    private void initialize_frame() {
      setVisible(true);
      setSize(600, 400);
/* Use the standard GUI-layout (without currency-selection)
 * as defined in the inherited class (JSBS_StartFrame). */
      setContentPane(get_pnl_Main());
    }

 
/*
 * -------------------------------
 * Method with code to be executed after the GUI is build */
    private void initialize_after_frame() {
    }

}

Contrary to the Command-Center (Start-Frame), this class does not have a main() - method.
It is undesired, to start a Task-Frame on its own as settings for the whole application (a set of Task-Frames) are held in the Command-Center and all Task-Frames are requested to access them.
Therefore, a Task-Frame has to be started from the Command-Center.

To do so, uncomment the responsible line in the class JS_ProjAssist_CommandCenter__ActionHandler.
(See Mandatory steps for developing a Start-Frame | Reacting to the button-click and open the Task-Frame where the lines had been commented out as the class for the Task-Frame did not exist at that time.)

 * -------------------------------
 * Method to get the selected code for the Business Task out of the entry-field
 * and call the frame with the chosen Business Task. */
    private static void openBusinessTask(JS_ProjAssist_CommandCenter parmCC){
/* 
 * Get the internal code using a combined method that also fills the parameter-fields.
 * Instead of the parameter-fields, 'null'-values are passed to signal the method
 * just to return the internal code. */
      String strInternalCode =
        parmCC.structJSBS_XML_Tasks.processParameterFields(parmCC.get_txt_Code(),
                                                           null, null, null, null, null, null);
/* Check which button was clicked and call the appropriate method. */
      if (strInternalCode.equals("P")) {
        JS_ProjAssist_Project frm_ JS_ProjAssist_Project = new JS_ProjAssist_Project(parmCC);
        frm_ JS_ProjAssist_Project.setVisible(true);
      }
    }

To verify, run the application, enter 'P' at the Selection field and click the button [ Continue ].

A Task-Frame will open that looks like that:



There is not text visible yet as the text is imported from a language dependant external file.
That will be covered in the next step.

top.

Define the language dependant GUI-elements and add the code to display it

The following step assumes, that the stardard layout (as defined in the inherited class JSBS_TaskFrame) should be used.

The basic work to access an external file with the XML-structure was already done with the Mandatdory steps for developing a Start-Frame | Define the language dependent GUI-elements and add the code to display it.

What has to be done for a Task-Frame is,

top.

Define the GUI-elements individual for the Task 'Project'

As you might have realised, till now there are no GUI-Elements within the JPanel pnl_Entry defined.
Those GUI-elements are individual for each Task-Frame.

To save some space, the additional code of the class (JS_ProjAssist_Project) is not copied into this document.
Please see the code following
 * GUI-elements individual for this Task. */

and the code following
 * Create the GUI-elements specific for this class.

Please click onto the green text to follow the link to the complete code.

After typing the additional code (or better: copy & paste it)
, run the application and you should get a frame like that:

top.

Create the Business Objects and the Database Access Objects

There might be already Business Objects (BO) and Database Access (DBA) Objects available for the Task you are working on which are waiting only to be used ;-).
In an early phase of the development of an application, however, it is unlikely that exactly the Business Objects and DBA Objects you need now already exist.

As developing Database Access Objects and Business Objects can be done independent from GUI-Design, the Step-By-Step instructions are described in a separate document. To get there, please follow this link.

top.

Implement the Client-Side Business Object

top.

React to the 'Store' button and write to the database

The following step assumes, that the class inherites from class JSBS_StartFrame.
Otherwise, the Interface ActionListener has to be implemented.

A more detailed description with screenshots how to react to a button-click and handle an action are in the documents JS_FC01i – Create and code the class for the 'Task-Frame to maintain 'Projects' and Base lesson 2, step 2: Adding an action: selecting the file with the SQL-commands.

As discussed in the documents above, it is wise to create an extra class for handling actions.
In catchwords:
Right click onto the package (js_projassist.clientframes in our example) and select >New>Class.
Enter the Package (xxx_project_xxx.clientframes) and
   the (Class-)Name (XXX_Project_XXX_CommandCenter__ActionHandler).
* Make sure that no checkbox is selected and click the [ Finish ] button
.

Copy the code from JS_ProjAssist_CommandCenter__ActionHandler into the just created class.
As there are no classes for the Task-Frames are defined now, some error will show.
Please comment out the lines with the 'construction' of the Task-Frame.
    private void initialize_before_frame(String parmstrLanguageCode) {
/*
 * Initialize the structure with the set of parameters
. . . . . . . . . . .

That the event can be handles, the following package has to be imported:
package js_projassist.clientframes;

import java.awt.event.*;

import js_base.frame.*;
import js_base.structures.*;

import js_base.xml.*;

Finally, a method actionPerformed(ActionEvent e) must be defined in the class JS_ProjAssist_CommandCenter.
This method is called when a button is clicked.
Its only function is to call the method handleEvent() in the just created class JS_ProjAssist_CommandCenter__ActionHandler and pass the parameter of class ActionEvent.

/*
 * -------------------------------
 * Method that is triggered when a button is clicked.
 * This method overwrites the method in the inherited class (JSBS_StartFrame). */
    public void actionPerformed(ActionEvent e) {
      JS_ProjAssist_CommandCenter__ActionHandler.handleEvent(this, e);
    }

top.

dummy for copying

top.

Related Documents: