> List of tutorials

Table of contents for this tutorial

Base-Class to read the file with a XML-structure for DisplayStrings - 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:
2007-01-25

This is document contains the code for Class JSBS_XML_DisplayStrings.
For easy 'cut and paste' ;-)

package js_base.xml;

import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

import
org.jdom.*;
import
js_base.structures.JSBS_UniversalParameters;
/**
 *
 * @author
kurt@javascout.biz
 * @date 2006-05-19
 *
 * @description
 *  Class with specialized methods for processing GUI-elements (except JButton).
 *  This class inherits JSBS_XML_Base and uses its methods to read a file
 *  containing a XML-structure.

 
*
 * @change-log
 * when         who               why
 * --------------------------------------------------------
 *
 */

public class JSBS_XML_DisplayStrings extends JSBS_XML_Base {
/*
 * -------------------------------
 * Constructor of the class */
    public JSBS_XML_DisplayStrings(JSBS_UniversalParameters parmUniversalParameters) {
/* Perform the code in the constructor of the inherited class */
        
super();
/* Get the filename for the XML-structure with the language dependant display-strings.
 * This is done by concatenating the directory with the language dependant files
 * and the filename for the file with the XML-structure. */
        String locstrFileName =
            
parmUniversalParameters.strTextElementsDirectoryName +
            
parmUniversalParameters.CONST_DISPLAYSTRINGS_FILE_NAME;

/* Read the RootElement (method implemented in the superclass - i.e. the class inherited) */
        
readXMLFile(locstrFileName);
    }

/*
 * ************************************************** */
/*
 * Method to search the XML-structure for the Title-Text of the frame */
    public int processJFrame(JFrame parmJFrame) {
/* 
 * Variables:
 */
/* Name of the class that is passed as parameter */
      
String strSearchedFrameClassName = parmJFrame.getClass().getName().trim();
/* Element for the <FrameIndividual> Division, element for one <Frame>,
 * element for the <FrameClass>, String with the name of the FrameClass,
 * element for the <FrameTitle> and String with the content of it. */
      
Element elementFrameIndividual;
      Element elementFrame;
      Element elementFrameClass;
      String strFrameClassName;
      Element elementFrameTitle;
/* List of all <Frame>-elements, size and index for searching it. */
      List listFrame;
      int intlistFrameSize;
      int intlistFrameIndex = 0;
/* 
 * General check if there are child-elements named <FrameIndividual> present. */
      
elementFrameIndividual = XML_RootElement.getChild("FrameIndividual");
      if (elementFrameIndividual == null) {
        StatusCode
= CONST_FRAMEINDIVIDUAL_DIVISION_NOT_PRESENT;
        return StatusCode;
      }

/* 
 * Get the list of <Frame>-elements and the number of elements within. */
      
listFrame = elementFrameIndividual.getChildren();
      intlistFrameSize = listFrame.size();
      if (intlistFrameSize == 0) {
        StatusCode
= CONST_FRAMECLASS_NOT_PRESENT;
        return StatusCode;
      }

/* 
 * Inspect each element of the list to find the element
   fitting the Class-Name of the JFrame passed as parameter. */
      for
(intlistFrameIndex = 0; intlistFrameIndex < intlistFrameSize; intlistFrameIndex++) {
        elementFrame = (Element) listFrame.get(intlistFrameIndex);
/* Get the element with the <FrameClass> to compare its content
 * with the Class-Name of the passed parameter. */
        elementFrameClass = elementFrame.getChild("FrameClass");
        if (elementFrameClass == null) {
          StatusCode
= CONST_FRAMECLASS_NOT_PRESENT;
          return StatusCode;
        
}
        strFrameClassName = elementFrameClass.getTextTrim();
        
if (strFrameClassName.compareTo(strSearchedFrameClassName) == 0) {
/* Fitting <Frame>-element found within the list; extract property for <FrameTitle>
 * and transfer it to the Title-Bar of JFrame (passed as parameter). */
          elementFrameTitle = elementFrame.getChild("FrameTitle");
          if (elementFrameTitle == null) {
            StatusCode
= CONST_FRAMETITLE_NOT_PRESENT;
            return StatusCode;
          
}
          parmJFrame.setTitle(elementFrameTitle.getTextTrim());
          StatusCode = CONST_OK;
          return StatusCode;
        }

      }
/* 
 * List searched without finding a <Frame>-element
with fitting class-name;
 * return the error. */
      StatusCode = CONST_FRAMECLASS_NOT_PRESENT;
      return StatusCode;
    
}
/*
 * ************************************************** */
/*
 * Method to get a DOM-Element belonging to the <FrameIndividual> division of the XML-structure */
    private Element getGUI_Element(String parmstrFrameClassName, String parmstrElementName) {
/* 
 * Variables:
 */
/* Element for the <FrameIndividual> Division, element for one <Frame>,
 * element for the <FrameClass>, String with the name of the FrameClass,
 * element for one GUI-Element within the <Frame>,
 * element for the <ElementName> and String with the content of it (the name). */
      
Element elementFrameIndividual;
      Element elementFrame;
      Element elementFrameClass;
      String  strFrameClassName;
      Element elementGUI_Element;
      Element elementElementName;
      String  strElementName;
/* List of all <Frame>-elements, size and index for searching it. */
      
List listFrame;
      int intlistFrameSize;
      int intlistFrameIndex = 0;
/* List of all GUI-<Element>-elements, size and index for searching it. */
      List listGUI_Element;
      int intlist
GUI_ElementSize;
      int intlistGUI_ElementIndex = 0;
/* 
 * Set the StatusCode to OK to see at the end of the method if anything went wrong. */
      StatusCode = CONST_OK;
/* 
 * General check if there are child-elements named <FrameIndividual> present. */
      
elementFrameIndividual = XML_RootElement.getChild("FrameIndividual");
      if (elementFrameIndividual == null) {
        StatusCode
= CONST_FRAMEINDIVIDUAL_DIVISION_NOT_PRESENT;
        return null;
      }
/* 
 * Get the list of <Frame>-elements and the number of elements within. */
      
listFrame = elementFrameIndividual.getChildren();
      intlistFrameSize = listFrame.size();
      if (intlistFrameSize == 0) {
        StatusCode
= CONST_FRAMECLASS_NOT_PRESENT;
        return null;
      }
/* 
 * Inspect each element of the list to find the element
   fitting the Class-Name of the JFrame passed as parameter. */
      for (intlistFrameIndex = 0; intlistFrameIndex < intlistFrameSize; intlistFrameIndex++) {
        elementFrame = (Element) listFrame.get(intlistFrameIndex);
/* Get the element with the <FrameClass> to compare its content
 * with the Class-Name of the passed parameter. */
        elementFrameClass = elementFrame.getChild("FrameClass");
        if (elementFrameClass == null) {
          StatusCode
= CONST_FRAMECLASS_NOT_PRESENT;
          return null;
        }
        strFrameClassName = elementFrameClass.getTextTrim();
        
if (strFrameClassName.compareTo(parmstrFrameClassName) == 0) {
/* Fitting <Frame>-element found within the list;
 * extract the list of GUI-elements and inspect each of it. */
          listGUI_Element = elementFrame.getChildren("Element");
          intlistGUI_ElementSize = listGUI_Element.size();
          if (intlistGUI_ElementSize == 0) {
            StatusCode
= CONST_GUI_ELEMENT_NOT_PRESENT;
            return null;
          }

          for (intlistGUI_ElementIndex = 0; intlistGUI_ElementIndex < intlistGUI_ElementSize; intlistGUI_ElementIndex++) {
            elementGUI_Element = (Element) listGUI_Element.get(intlistGUI_ElementIndex);
/* Get the element <ElementName> to compare its content (name of the GUI-element)
 * and compare it with the name of the GUI-element
passed as parameter. */
            elementElementName = elementGUI_Element.getChild("ElementName");
            if (elementElementName == null) {
/* Found a GUI-element without a name.
 * Should not happen but is not a reason to end; skip further inspection */
              strElementName = "";
            }

            else {
              strElementName = elementElementName.getTextTrim();
            }

            if (strElementName.compareTo(parmstrElementName) == 0) {
/* Fitting element found within the XML-structure;
 * check if there are properties at a <CommonElement> and merge if necessary.
 * Check and merge is done in a separate method to limit the depth of 'for' and 'if'
 * hierachies in this method. */
              mergeCommonElementProperties(elementGUI_Element);
              return elementGUI_Element;
            }
          
}

        
}

      }
/* Searched GUI-element not found within the XML-structure; return the error. */
      StatusCode
= CONST_GUI_ELEMENT_NOT_PRESENT;
      return null;
    
}

/*
 * ************************************************** */
/*
 * Method to check if properties are defined within a DOM-element belonging to the <CommonElements>
 * and – if one exists – transfer its properties */
    private void mergeCommonElementProperties(Element parmelementGUI_Element) {
/* 
 * Variables:
 
* element for the <CommonElementReference> and String with the content of it. */
      
Element elementCommonElementReference;
      String  strCommonElementReference;
/*
 * Elements containing the properties of the one passed as parameter
. */
      
Element elementElementText_Param;
      Element elementToolTipText_Param;
/* 
 * Test if the element with the pointer to the CommonElement is present. */
      
elementCommonElementReference = parmelementGUI_Element.getChild("CommonElementReference");
      if (elementCommonElementReference == null) {
/* No reference present; further processing can be skipped. */
        
return;
      }
/* Get the name of the <CommonReference>-element and then call the method to get it. */
      
strCommonElementReference = elementCommonElementReference.getTextTrim();
      Element locelementCommonReference = getCommonElement(strCommonElementReference);
      if (locelementCommonReference == null) {
/* Referenced element not found; should not happen – so report an error. */
        StatusCode = CONST_GUI_ELEMENT_COMMON_NOT_PRESENT;
        return;
      }
/*
 * Transfer properties from the <CommonElement> (just fetched)
 * to the element passed as parameter. 
 * Explanation of the algorithm only for the first transfer. */
      
String strElementVariableName = "ElementText";
/* Check if property was not individually defined. */
      
elementElementText_Param = parmelementGUI_Element.getChild(strElementVariableName);
      if ( elementElementText_Param == null) {
/* Element not found; use property from <CommonElement> if present. */
        Element locelementElementText_Common = locelementCommonReference.getChild(strElementVariableName);
        if (locelementElementText_Common != null) {
/* Element found as property with the <CommonElement>;
 * transfer data to the element passed as parameter. */
          Element locelementElementText_New = new Element(strElementVariableName);
          locelementElementText_New.setText(locelementElementText_Common.getTextTrim());
          parmelementGUI_Element.addContent(locelementElementText_New);
        
}
      
}
/* Transfer ToolTipText. */
      
strElementVariableName = "ToolTipText";
      elementToolTipText_Param = parmelementGUI_Element.getChild(strElementVariableName);
      if ( elementToolTipText_Param == null) {
        Element locelementToolTipText_Common = locelementCommonReference.getChild(strElementVariableName);
        if (locelementToolTipText_Common != null) {
          Element locelementToolTipText_New = new Element(strElementVariableName);
          locelementToolTipText_New.setText(locelementToolTipText_Common.getTextTrim());
          parmelementGUI_Element.addContent(locelementToolTipText_New);
        
}
      
}
    
}
/*
 * ************************************************** */
/*
 * Method to get a DOM-Element belonging to the <CommonElements> division of the XML-structure */
    private Element getCommonElement(String parmstrElementName) {
/* 
 * Variables:
 */
/* Element for the <CommonElements> Division, element for one <CommonElement>,
 * element for the <CommonElementName> and String with the content of it (the name). */
      
Element elementCommonElements;
      Element elementCommonElement;
      Element elementGUI_Element;
      Element elementCommonElementName;
      String  strCommonElementName;
/* List of all <CommonElement>-elements, size and index for searching it. */
      
List listCommonElement;
      int intlist
CommonElementSize;
      int intlistCommonElementIndex = 0;
/* 
 * General check if there are child-elements named <CommonElements> present. */
      
elementCommonElements = XML_RootElement.getChild("CommonElements");
      if (elementCommonElements == null) {
        StatusCode
= CONST_COMMONELEMENTS_DIVISION_NOT_PRESENT;
        return null;
      }
/* 
 * Get the list of <CommonElement>-elements and the number of elements within. */
      
listCommonElement = elementCommonElements.getChildren();
      intlistCommonElementSize = listCommonElement.size();
      if (intlistCommonElementSize == 0) {
        StatusCode
= CONST_COMMONELEMENTS_DIVISION_NOT_PRESENT;
        return null;
      }
/* 
 * Inspect each element of the list to find the element
   fitting the element-name passed as parameter. */
      for (intlistCommonElementIndex = 0; intlistCommonElementIndex < intlistCommonElementSize; intlistCommonElementIndex++) {
        element
CommonElement = (Element) listCommonElement.get(intlistCommonElementIndex);
/* Get the element with the <ElementName> to compare its contents with the passed parameter. */
        elementCommonElementName = elementCommonElement.getChild("ElementName");
        if (elementCommonElementName != null) {
/* Compare if the element was found; otherwise skip and do not consider it as error. */
          strCommonElementName = elementCommonElementName.getTextTrim();
          if (strCommonElementName.compareTo(parmstrElementName) == 0) {
/* Fitting <CommonElement>-element found within the list; return it ! */
            return elementCommonElement;
          }

        
}
      
}
/* Searched common-element not found within the XML-structure; return the error. */
      StatusCode
= CONST_GUI_ELEMENT_COMMON_NOT_PRESENT;
      return null;
    
}

/*
 * ************************************************** */
/*
 * Method to transfer the properties defined in the XML-structure
 * to a GUI-element of type JLabel */

    public int processJLabel(JLabel parmJLabel, String parmstrFrameClassName) {
/*
 * Variables:
 */
/* Fitting element out of the XML-structure and
 * elements representing all properties to be transferred to the JLabel */
      Element elementGUI_Element;
      Element elementGUI_ElementText;
      Element elementGUI_ToolTipText;
/*
 * Name of the JLabel; used as identifier to get the fitting GUI-element out of the XML-structure */
      String strLabelName = parmJLabel.getName();
/* Verify if the element has a name; otherwise there is unpredicted behaviour */
      if
(strLabelName != null) {
/*
 * Get the fitting GUI-element using the method implemented above */
        elementGUI_Element = getGUI_Element(parmstrFrameClassName, strLabelName);
        if (elementGUI_Element == null) {
          StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;
          return StatusCode;
        }
 /*
 * Transfer the properties of the GUI-element to the JLabel passed as parameter */
        elementGUI_ElementText = elementGUI_Element.getChild("ElementText");
        if (elementGUI_ElementText != null) parmJLabel.setText(elementGUI_ElementText.getTextTrim());
        elementGUI_ToolTipText = elementGUI_Element.getChild("ToolTipText");
        if (elementGUI_ToolTipText != null) parmJLabel.setToolTipText(elementGUI_ToolTipText.getTextTrim());
      }
      else {StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;}
/*
 * Return the Status-code of this class; it reflects if errors occured during processing */
      return StatusCode;
    }
/*
 * ************************************************** */
/*
 * Method to transfer the properties defined in the XML-structure to a GUI-element of type JButton */

    public int processJButton(JButton parmJButton, String parmstrFrameClassName) {
/*
 * Variables:
 */
/* Fitting element out of the XML-structure and
 * elements representing all properties to be transferred to the JLabel */

      Element elementGUI_Element;
      Element elementGUI_ElementText;
      Element elementGUI_ToolTipText;
/*
 * Name of the JButton; used as identifier to get the fitting GUI-element out of the XML-structure */

      String strButtonName = parmJButton.getName();
/* Verify if the element has a name; otherwise there is unpredicted behaviour */
      if (strButtonName != null) {
/*
 * Get the fitting GUI-element using the method implemented above */

        elementGUI_Element = getGUI_Element(parmstrFrameClassName, strButtonName);
        if (elementGUI_Element == null) {
          StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;
          return StatusCode;
        }
/*
 * Transfer the properties of the GUI-element to the JButton passed as parameter */

        elementGUI_ElementText = elementGUI_Element.getChild("ElementText");
        if (elementGUI_ElementText != null) parmJButton.setText(elementGUI_ElementText.getTextTrim());
        elementGUI_ToolTipText = elementGUI_Element.getChild("ToolTipText");
        if (elementGUI_ToolTipText != null) parmJButton.setToolTipText(elementGUI_ToolTipText.getTextTrim());
      }
      else {StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;}
/*
 * Return the Status-code of this class; it reflects if errors occured during processing */

      return StatusCode;
    }
/*
 * ************************************************** */
/*
 * Method to transfer the properties defined in the XML-structure
 * to a GUI-element of type JTable */

    public int processJTable(JTable parmJTable, String parmstrFrameClassName,
                             Vector parmvecRawData, String[] parmarrayColumnWidth) {
/*
 * Variables:
 */
/* Fitting element out of the XML-structure and
 * elements representing all properties to be transferred to the JTable */
      Element elementGUI_Element;
      Element elementTableHeaderColumns;
      Element elementColumn;
      Element elementSymbolicName;
      String strSymbolicName;
      Element elementElementText;
      String strElementText;
      Element elementWidth;
      String strWidth;
/* Lists out of the XML-structure; their size and indexes for them */
      List listColumn;
      int intlistColumnSize;
      int intlistColumnIndex;
/* Vectors used within this method */
      Vector vecSymbolicNamesForColumns = new Vector();
      Vector vecHeaderTextForColumns = new Vector();
/* Flag to signal that column-width definitions from XML-file override others.
 * This flag is set to true if the number of columns was changed. */
      boolean bolUseColumnWidthDefinitionFromXML = false;
/*
 * Name of the JTable; used as identifier to get the fitting GUI-element out of the XML-structure */
      String strTableName = parmJTable.getName();
/* Verify if the element has a name; otherwise there is unpredicted behaviour */
      if (strTableName == null) {
        StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;
        return StatusCode;
      }
/*
 * Get the fitting GUI-element using the method implemented above */
      elementGUI_Element = getGUI_Element(parmstrFrameClassName, strTableName);
      if (elementGUI_Element == null) {
        StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;
        return StatusCode;
      }
/*
 * Extract the element holding all properties for the columns of a JTable */
      elementTableHeaderColumns = elementGUI_Element.getChild(
"TableHeaderColumns");
      if (elementTableHeaderColumns == null) {
        StatusCode = CONST_GUI_ELEMENT_NOT_PRESENT;
        return StatusCode;
      }
/* Get the list of XML-elements defining properties for the 'column's */
      listColumn = elementTableHeaderColumns.getChildren("Column");
      intlistColumnSize = listColumn.size();
/*
 * Check if the number of columns out of the XML-file still fits
 * the size of the array passed as parameter. */
      if (intlistColumnSize != parmarrayColumnWidth.length) {
/* Change in the number of columns; build a new array and set the flag. */
        parmarrayColumnWidth = new String[intlistColumnSize];
        bolUseColumnWidthDefinitionFromXML =
true;
      }
/*
 * Process each element of the list */
      
for (intlistColumnIndex = 0;
           
intlistColumnIndex < intlistColumnSize;
           
intlistColumnIndex++)
{
/* Retrieve each XML-element for a column */
        elementColumn = (Element) listColumn.get(intlistColumnIndex);
/* If the requested element was found, process the elements underneath it */
        if (elementColumn != null) {
/* The order of the 'Column' elements defines the order how the columns of data
 * are arranged within the JTable */
          elementSymbolicName = elementColumn.getChild("SymbolicName");
/* The 'SymbolicName' is the program-internal name of a variable.
 * This variable is also present in row 0 of the RawDataVector (passed as parameter)
 * and defines in which column of the JTable the data of the specified column of the
 * RawDataVector should be displayed. The filling of the JTable is done later */
          if (elementSymbolicName != null) strSymbolicName = elementSymbolicName.getTextTrim();
          else strSymbolicName = "";
          vecSymbolicNamesForColumns.addElement(strSymbolicName);

/*
 * The 'ElementText' is the language-specific text for the column in the header of the JTable */
          elementElementText = elementColumn.getChild("ElementText");
          if (elementElementText != null) strElementText = elementElementText.getTextTrim();
          else strElementText = "";
          vecHeaderTextForColumns.addElement(str
ElementText);

/*
 * The 'ColumnWidth' is a proportional value of the width of the columns of the JTable.
 * If an array was passed as a parameter, then the values with in the passed array
 * are taken to size the column width of the displayed JTable.
 * If the array passed as parameter does not fit the number of columns from the XML-file,
 * then the additional values are taken out of the XML-file. */
          if (bolUseColumnWidthDefinitionFromXML) {
/* Column-Width information _not_ passed within the parameter;
 * take the information out of the XML-file. */
            elementWidth = elementColumn.getChild("Width");
            if (elementWidth != null) strWidth = elementWidth.getTextTrim();
            else strWidth = "";
            parmarrayColumnWidth[intlistColumnIndex] = strWidth;
          }

        }

      }
/*
 * Save the width of the table-columns – if columns already esist. */
      TableColumnModel locColumnModel = null;
      locColumnModel = parmJTable.getColumnModel();
/* Get the number of cokumns that already exist within the table.
 * That might be 0 if the table was not already populated. */
      int intTableColumnCount = locColumnModel.getColumnCount();
/* Get the column-width for each column. */
      for (int intTableColumnIndex = 0;
           
intTableColumnIndex
< intTableColumnCount;
           
intTableColumnIndex++
) {
/* Check if the array passed as parameter is large enough.
 * The number of columns might have changed inbetween. */
        if (intTableColumnIndex < parmarrayColumnWidth.length) {
          parmarrayColumnWidth[intTableColumnIndex] =
            Integer.toString(locColumnModel.getColumn(intTableColumnIndex).getWidth());
        };

      }
/*
 * Rebuild the content of the JTable. */
/* 
 * First, build a vector suitable for the data of the JTable.
 * This is done in an own method to avoid overloading of this method. */
      Vector vecTableData = getFieldData(parmvecRawData, vecSymbolicNamesForColumns);
/* 
 * Second, refill the content of the JTable.
 * The procedure is a little bit compicated as table-data can not be directly adressed
 * by row/column. */
      JTable locJTable = new JTable(vecTableData, vecHeaderTextForColumns);
      TableModel locTableModel = locJTable.getModel();
      parmJTable.setModel(locTableModel);
/*
 * Disable some features of JTable; this is done that a user does not get confused if
 * she/he
changes the width of a single column
 * 
or erratically changes the column-order or selects a whole column. */
      parmJTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
      parmJTable.getTableHeader().setReorderingAllowed(false);
      parmJTable.getColumnModel().setColumnSelectionAllowed(false);
/*
 * Set the width of the columns. */
      locColumnModel = parmJTable.getColumnModel();
/* Number of pixels that are available for all columns. */
      int intTableTotalColumnWidth = locColumnModel.getTotalColumnWidth();
/* Sum of pixels that are requiered by the parameter in the XML-structure.
 * Together with the sum of pixels available in the table, a proportion is calculated later. */
      int intDefinedTotalColumnWidth = 0;
/* Auxilliary variable to hold the defined width of one column. */
      int intSingleColumnWidth;
/*
 * Accumulate the number of pixels for the table-width as defined in the XML-structure. */
      intTableColumnCount = parmarrayColumnWidth.length;
      
for (int intTableColumnIndex = 0;
           
intTableColumnIndex < intTableColumnCount;
           
intTableColumnIndex++)
{
/* Convert the (String) value from the XML-structure or passed as parameter
 * to an int-value. */
        try {
          intSingleColumnWidth =
            Integer.parseInt(parmarrayColumnWidth[intTableColumnIndex]);
        }
        catch (Exception exc) { intSingleColumnWidth = 1;}
/* Add the value to the sum of column width defined in the XML-structure. */
        intDefinedTotalColumnWidth += intSingleColumnWidth;
      }
/*
 * Set the column-with of the JTable. */
      for (int intTableColumnIndex = 0;
           
intTableColumnIndex < intTableColumnCount;
           
intTableColumnIndex++)
{
/* Convert the (String) value from the XML-structure or passed as parameter
 * to an int-value. */
        try {
          intSingleColumnWidth =
            Integer.parseInt(parmarrayColumnWidth[intTableColumnIndex]);
        }
        catch (Exception exc) { intSingleColumnWidth = 1;}
/* Calculate the table-width.
 * This might be different from the value from the parameter or the XML-structure. */
        intSingleColumnWidth =
          intSingleColumnWidth * intTableTotalColumnWidth / intDefinedTotalColumnWidth;
/* Set the width of a single column. */
        locColumnModel.getColumn(intTableColumnIndex).setPreferredWidth(intSingleColumnWidth);
      }
/*
 * Return the Status-code of this class; it reflects if errors occured during processing */
      return StatusCode;
    }
/*
 * ************************************************** */
/*
 * Method to build the data-vector that is needed to fill the fields of a JTable.
 * The columns of the JTable are sorted according to the definition passed with
 * parameter 'parmvecSymbolicNames'.
 * This parameter originates from the order defined in file 'DisplayStrings.xml'. */

    private Vector getFieldData(Vector parmvecRawData, Vector parmvecSymbolicColumnNames) {
/*
 * Variables:
 */
/* Vector to be returned */
      Vector vecTableData = new Vector();
/* Number of rows in the raw data passed as parameter and index for it */
      int intvecRawDataSize = parmvecRawData.size();

      int intvecRawDataIndex;
/* Ordering of columns of the raw data vector.
 * This information is in the first element of the vector (index 0). */
      Vector vecRawDataSymbolicColumnNames = new Vector();
      
if (intvecRawDataSize > 0) {
        vecRawDataSymbolicColumnNames = (Vector) parmvecRawData.elementAt(0);
      }
/* Number of rows in the raw data passed as parameter and index for it. */
      int intvecRawDataSymbolicColumnNamesSize = vecRawDataSymbolicColumnNames.size();
      int intvecRawDataSymbolicColumnNamesIndex;
/* Number of columns of the vector the symbolic names (passed as parameter and
 * defining the ordering of columns) and index for it. */
      int intvecSymbolicColumnNamesSize = parmvecSymbolicColumnNames.size();
      int intvecSymbolicColumnNamesIndex;
/* Some String-variables to handle the content of the vectors. */
      String strFieldValue;
      String strRawDataSymbolicColumnName;
      String strSymbolicColumnName;
/* Vector representing one 'row' within the raw data vector */
      Vector vecRawDataRow;
/*
 * Go through each 'row' of the raw data.
 * This starts with index 1 as the element with index 0 contains the symbolic column names. */
      
for (intvecRawDataIndex = 1;
           
intvecRawDataIndex < intvecRawDataSize;
           
intvecRawDataIndex++)
{
/* Retrive one element representing a 'row' for the table. */
        vecRawDataRow = (Vector) parmvecRawData.elementAt(intvecRawDataIndex);
/* Create a vector which will be the 'row' for the JTable. */
        Vector vecJTableDataRow = new Vector();
/*
 * Go through vector with the Symbolic Column Names in the order for display.
 * This vector is build according the order in file 'DisplayStrings.xml'. */
        for (intvecSymbolicColumnNamesIndex = 0;
             
intvecSymbolicColumnNamesIndex < intvecSymbolicColumnNamesSize;
             
intvecSymbolicColumnNamesIndex++)
{
/* Get the name of the symbolic column out of the vector. */
          strSymbolicColumnName =
            (String) parmvec
SymbolicColumnNames.elementAt(intvecSymbolicColumnNamesIndex);
/* Fill the field to be displayed in JTable with an empty string.
 * This is a precaution if no value is found in the following processing. */
          strFieldValue = "";
/*
 * Find out in which column of the raw data vector the requested column
 * (defined by the symbolic column name acquiered in the higher-ranking for-loop). */
          for (intvecRawDataSymbolicColumnNamesIndex = 0;
               
intvecRawDataSymbolicColumnNamesIndex < intvecRawDataSymbolicColumnNamesSize;
               
intvecRawDataSymbolicColumnNamesIndex++)
{
/* Compare, if the 'column' in the raw data matches. */
            strRawDataSymbolicColumnName =
              (String) vecRawData
SymbolicColumnNames.elementAt(intvecRawDataSymbolicColumnNamesIndex);
            
if (((strRawDataSymbolicColumnName.trim()).compareTo(
                   strSymbolicColumnName.trim())) == 0) {
/* Fitting 'column' in the raw data found. */
/* First check if the vector representing a 'row' really contains all data.
 * This should not happen theoretically – but if, the program dumps. */
              
if (vecRawDataRow.size() > intvecRawDataSymbolicColumnNamesIndex) {
/* Transfer value for the JTable field. */
                strFieldValue = (String) vecRawDataRow.elementAt(intvecRawDataSymbolicColumnNamesIndex);
              }

/* Field-value transferred; no more need to continue within the loop. */
              break ;
            }

          }
/* Add the acquiered field-value to the vector representing one row of the JTable. */
    
      vecJTableDataRow.addElement(strFieldValue);
          strFieldValue =
new String();

        }
/* Add the vector representing one row of the JTable to the vector with all rows. */
  
      vecTableData.addElement(vecJTableDataRow);
  
    }
      return vecTableData;
    }
}