> List of tutorials

Table of contents for this tutorial

Fat-Client-Development - Code for Class JS_ErrDB_CommandCenter

* 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 linked within 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-05-05

This is document contains the code for Class JS_ErrDB_CommandCenter.
This class contains variables and methods used for all StartFrames (CommandCenter) of application-programs.
For easy 'cut and paste' ;-)

package js_errdb.clientframes;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import js_base.connections.JSBS_DB_ConnectionManager;
import
js_base.frame.*;
import
js_base.structures.*;
import js_base.xml.*;

/**
 *
 * @author
kurt@javascout.biz
 * @date 2006-05-07
 *
 * @description
 * Command Center for the Fat-Client-Application to maintain
 * the database with the error-messages
 
*
 * @change-log
 * when who why
 * --------------------------------------------------------
 *
 */

public class JS_ErrDB_CommandCenter extends
JSBS_StartFrame implements JSBS_XML_Constants, ActionListener {

    private JPanel pnl_Main=null;
    private JLabel lbl_Welcome=null;
    private JButton btn_Maintain=null;
/*
 * -------------------------------
 * Constructor of the class */
    
public JS_ErrDB_CommandCenter(String parmstrLanguageCode){
      super();
      initialize_before_frame(parmstrLanguageCode);
      initialize_frame();
      initialize_after_frame();
    }

 
    private JLabel get_lbl_Welcome() {
/* The code of this method auto-creates the element if it is not already defined */
      if (lbl_Welcome == null) {
        try {
          lbl_Welcome = new JLabel();
          lbl_Welcome.setName("lbl_Welcome");
          lbl_Welcome.setText(".....");
        }
        catch (Throwable Exc) {
          System.out.println("Error while building lbl_Welcome");
          Exc.printStackTrace();
        }
      }
      return lbl_Welcome;
    }

 
    
private JButton get_btn_Maintain() {
/* The code of this method auto-creates the element if it is not already defined */

      if (btn_Maintain == null) {
        try {
          btn_Maintain = new JButton();
          btn_Maintain.setName("btn_Maintain");
          btn_Maintain.addActionListener(this);
          btn_Maintain.setActionCommand("btn_Maintain");
        }
        catch (Throwable Exc) {
          System.out.println("Error while building btn_Maintain");
          Exc.printStackTrace();
        }
      }
      return btn_Maintain;
    }

 
    public JPanel get_pnl_Main() {
/* The code of this method auto-creates the element if it is not already defined */

      if (pnl_Main == null) {
        try {
          pnl_Main = new JPanel();
          pnl_Main.setName("pnl_Main");
          pnl_Main.setLayout(new GridBagLayout());
/*
 * Define GridBagConstraints for the element to be added */

          
GridBagConstraints gbc_lbl_Welcome = new GridBagConstraints();
          gbc_lbl_Welcome.gridx = 0;
          gbc_lbl_Welcome.gridy = 0;
          gbc_lbl_Welcome.fill = GridBagConstraints.HORIZONTAL;
          gbc_lbl_Welcome.weightx = 1;
          gbc_lbl_Welcome.anchor = GridBagConstraints.CENTER;
/* Add the element to the Panel; element-position is controlled by GridBagConstraints */
          get_pnl_Main().add(get_lbl_Welcome(), gbc_lbl_Welcome);
/*
 * Define GridBagConstraints for the element to be added */

          GridBagConstraints gbc_btn_Maintain = new GridBagConstraints();
          gbc_btn_Maintain.gridx = 0;
          gbc_btn_Maintain.gridy = 1;
          gbc_btn_Maintain.fill = GridBagConstraints.HORIZONTAL;
          gbc_btn_Maintain.weightx = 1;
          gbc_btn_Maintain.anchor = GridBagConstraints.CENTER;
/* Add the element to the Panel; element-position is controlled by GridBagConstraints */
          get_pnl_Main().add(get_btn_Maintain(), gbc_btn_Maintain);
        }
        catch (Throwable Exc) {
          System.out.println("Error while building pnl_Main");
          Exc.printStackTrace();
        }
      }
      return pnl_Main;
    }

 
    private void initialize_before_frame(String parmstrLanguageCode) {
/* Initialize the structure with the set of parameters */
      structJSBS_UniversalParameters = new JSBS_UniversalParameters(parmstrLanguageCode);
/* Initialize the structure with the XML-Element for language dependant GUI-elements
 * (except JButton). */

      structJSBS_XML_DisplayStrings = new JSBS_XML_DisplayStrings(structJSBS_UniversalParameters);
/* Verifiy if the class was constructed without an error. */
      
if (structJSBS_XML_DisplayStrings.StatusCode != CONST_OK){
        System.out.println("Error while building 'structJSBS_XML_DisplayStrings'; StatusCode: " + (new Integer(structJSBS_XML_DisplayStrings.StatusCode)).toString());
        System.exit(structJSBS_XML_DisplayStrings.StatusCode);
      }

/* 
 * Define, that the configuration of the application is with a local database (Stand-Alone). */
      
RunVersion = CONST_StandAlone;
/* 
 * Establish the connection to the database-system and/or the JAS -
 * depending on the RunVersion. */
      
if ((RunVersion == CONST_StandAlone) || (RunVersion == CONST_MobileClient)) {
        structJSBS_DB_ConnectionManager =
          new
JSBS_DB_ConnectionManager(structJSBS_UniversalParameters);
/* Verify if the class was constructed without an error. */
        if (structJSBS_DB_ConnectionManager.StatusCode != JSBS_XML_Constants.CONST_OK) {
          System.out.println("Error while building 'structJSBS_DB_ConnectionManager'; StatusCode: " +
            (new Integer(structJSBS_DB_ConnectionManager.StatusCode)).toString() +
            
"; StatusMessage: " + structJSBS_DB_ConnectionManager.StatusMsg)
;
          System.exit(structJSBS_DB_ConnectionManager.StatusCode);
        }

      }
    }

 
    private void initialize_frame() {
      setVisible(true);
      setSize(600, 400);
      setTitle("JavaScout-Tutorial – Fat-Client-01 – Maintain Error-Messages");
      setContentPane(get_pnl_Main());
    }

 
    private void initialize_after_frame() {
      JSBS_GUIServices.processLanguageDependantElements(this);
    }

 
    public void actionPerformed(ActionEvent e) {
      JS_ErrDB_CommandCenter__ActionHandler.handleEvent(this, e);
    }

 
    /*
     * @param args
     */

    public static void main(String[] args) {
      String locstrLanguageCode = "";
      if (args.length > 0) locstrLanguageCode = args[0];
      try {
        JS_ErrDB_CommandCenter aJS_ErrDB_CommandCenter = new JS_ErrDB_CommandCenter(locstrLanguageCode);
      }
      catch(Throwable exc) {
        System.out.println("Exception occured in main() of JS_ErrDB_CommandCenter");
        exc.printStackTrace(System.out);
      }
    }

}