home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / CustomerInfoPanel.java < prev    next >
Text File  |  1998-05-08  |  15KB  |  327 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20. package borland.samples.intl.gui.resources;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.util.*;
  25. import borland.jbcl.layout.*;
  26. import borland.jbcl.control.*;
  27. import borland.jbcl.dataset.*;
  28.  
  29. import borland.samples.intl.application.*;
  30. import borland.samples.intl.beans.*;
  31. import borland.samples.intl.beans.event.*;
  32. import borland.samples.intl.gui.*;
  33.  
  34.  
  35. /**
  36.  * CustomerInfoPanel for United States address format.
  37.  */
  38. public class CustomerInfoPanel extends Panel implements InterchangeableCustomerInfoPanel {
  39.   AppDataModule appDataModule = AppDataModule.getDataModule();
  40.  
  41.   FieldControl address1Field = new FieldControl();
  42.   FieldControl address2Field = new FieldControl();
  43.   FieldControl cityField = new FieldControl();
  44.   FieldControl countryField = new FieldControl();
  45.   FieldControl emailField = new FieldControl();
  46.   FieldControl faxField = new FieldControl();
  47.   FieldControl firstNameField = new FieldControl();
  48.   FieldControl lastNameField = new FieldControl();
  49.   FieldControl middleNameField = new FieldControl();
  50.   FieldControl phoneField = new FieldControl();
  51.   FieldControl postalCodeField = new FieldControl();
  52.   FieldControl provinceField = new FieldControl();
  53.  
  54.   LabelControl address1Label = new LabelControl();
  55.   LabelControl address2Label = new LabelControl();
  56.   LabelControl cityLabel = new LabelControl();
  57.   LabelControl countryLabel = new LabelControl();
  58.   LabelControl emailLabel = new LabelControl();
  59.   LabelControl faxLabel = new LabelControl();
  60.   LabelControl firstNameLabel = new LabelControl();
  61.   LabelControl lastNameLabel = new LabelControl();
  62.   LabelControl middleNameLabel = new LabelControl();
  63.   LabelControl phoneLabel = new LabelControl();
  64.   LabelControl postalCodeLabel = new LabelControl();
  65.   LabelControl provinceLabel = new LabelControl();
  66.  
  67.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  68.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  69.   GridBagLayout gridBagLayout3 = new GridBagLayout();
  70.   GridBagLayout gridBagLayout4 = new GridBagLayout();
  71.   GridBagLayout gridBagLayout5 = new GridBagLayout();
  72.   GridBagLayout gridBagLayout6 = new GridBagLayout();
  73.  
  74.   BevelPanel bevelPanel1 = new BevelPanel();
  75.   BevelPanel bevelPanel2 = new BevelPanel();
  76.   BevelPanel bevelPanel3 = new BevelPanel();
  77.   BevelPanel bevelPanel4 = new BevelPanel();
  78.   BevelPanel bevelPanel5 = new BevelPanel();
  79.   BevelPanel bevelPanel6 = new BevelPanel();
  80.  
  81.   GridLayout gridLayout1 = new GridLayout();
  82.  
  83.   ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes",
  84.                                                               LocaleChangeManager.getLocale());
  85.  
  86.   public CustomerInfoPanel() {   
  87.     try {
  88.       jbInit();
  89.     }
  90.     catch (Exception e) {
  91.       e.printStackTrace();
  92.     }
  93.   }
  94.  
  95.   public void jbInit() throws Exception{
  96.  
  97.     firstNameLabel.setAlignment(Label.RIGHT);
  98.     firstNameLabel.setText(textRes.getString("first_name"));
  99.  
  100.     firstNameField.setColumnName("first_name");
  101.     firstNameField.setDataSet(appDataModule.getCustomerDataSet());
  102.  
  103.     middleNameLabel.setAlignment(Label.RIGHT);
  104.     middleNameLabel.setText(textRes.getString("middle_name"));
  105.  
  106.     middleNameField.setColumnName("middle_name");
  107.     middleNameField.setDataSet(appDataModule.getCustomerDataSet());
  108.  
  109.     lastNameLabel.setAlignment(Label.RIGHT);
  110.     lastNameLabel.setText(textRes.getString("last_name"));
  111.  
  112.     lastNameField.setColumnName("last_name");
  113.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  114.  
  115.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  116.     bevelPanel1.setLayout(gridBagLayout1);
  117.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  118.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  119.     bevelPanel1.add(firstNameField, new GridBagConstraints2(1, 0, 3, 1, 45.0, 0.0
  120.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  121.     bevelPanel1.add(middleNameLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  122.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  123.     bevelPanel1.add(middleNameField, new GridBagConstraints2(5, 0, 3, 1, 10.0, 0.0
  124.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  125.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  126.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  127.     bevelPanel1.add(lastNameField, new GridBagConstraints2(9, 0, 3, 1, 45.0, 0.0
  128.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  129.     this.add(bevelPanel1, null);
  130.  
  131.     address1Label.setAlignment(Label.RIGHT);
  132.     address1Label.setText(textRes.getString("address1"));
  133.  
  134.     address1Field.setColumnName("address1");
  135.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  136.  
  137.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  138.     bevelPanel2.setLayout(gridBagLayout2);
  139.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  140.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  141.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  142.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  143.     this.add(bevelPanel2, null);
  144.  
  145.     address2Label.setAlignment(Label.RIGHT);
  146.     address2Label.setText(textRes.getString("address2"));
  147.  
  148.     address2Field.setColumnName("address2");
  149.     address2Field.setDataSet(appDataModule.getCustomerDataSet());
  150.  
  151.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  152.     bevelPanel3.setLayout(gridBagLayout3);
  153.     bevelPanel3.add(address2Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  154.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  155.     bevelPanel3.add(address2Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  156.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  157.     this.add(bevelPanel3, null);
  158.  
  159.     cityLabel.setAlignment(Label.RIGHT);
  160.     cityLabel.setText(textRes.getString("city"));
  161.  
  162.     cityField.setColumnName("city");
  163.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  164.  
  165.     provinceLabel.setAlignment(Label.RIGHT);
  166.     provinceLabel.setText(textRes.getString("province"));
  167.  
  168.     provinceField.setColumnName("province");
  169.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  170.  
  171.     postalCodeLabel.setAlignment(Label.RIGHT);
  172.     postalCodeLabel.setText(textRes.getString("postal_code"));
  173.  
  174.     postalCodeField.setColumnName("postal_code");
  175.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  176.  
  177.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  178.     bevelPanel4.setLayout(gridBagLayout4);
  179.     bevelPanel4.add(cityLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  180.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  181.     bevelPanel4.add(cityField, new GridBagConstraints2(1, 0, 3, 1, 80.0, 0.0
  182.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  183.     bevelPanel4.add(provinceLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  184.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  185.     bevelPanel4.add(provinceField, new GridBagConstraints2(5, 0, 3, 1, 10.0, 0.0
  186.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  187.     bevelPanel4.add(postalCodeLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  188.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  189.     bevelPanel4.add(postalCodeField, new GridBagConstraints2(9, 0, 3, 1, 10.0, 0.0
  190.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  191.     this.add(bevelPanel4, null);
  192.  
  193.     countryLabel.setAlignment(Label.RIGHT);
  194.     countryLabel.setText(textRes.getString("country"));
  195.  
  196.     countryField.setColumnName("country");
  197.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  198.  
  199.     emailLabel.setAlignment(Label.RIGHT);
  200.     emailLabel.setText(textRes.getString("e_mail"));
  201.  
  202.     emailField.setColumnName("e_mail");
  203.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  204.  
  205.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  206.     bevelPanel5.setLayout(gridBagLayout6);
  207.     bevelPanel5.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  208.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  209.     bevelPanel5.add(countryField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  210.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  211.     bevelPanel5.add(emailLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  212.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  213.     bevelPanel5.add(emailField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  214.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  215.     this.add(bevelPanel5, null);
  216.  
  217.     phoneLabel.setAlignment(Label.RIGHT);
  218.     phoneLabel.setText(textRes.getString("phone"));
  219.  
  220.     phoneField.setColumnName("phone");
  221.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  222.  
  223.     faxLabel.setAlignment(Label.RIGHT);
  224.     faxLabel.setText(textRes.getString("fax"));
  225.  
  226.     faxField.setColumnName("fax");
  227.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  228.  
  229.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  230.     bevelPanel6.setLayout(gridBagLayout5);
  231.     bevelPanel6.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  232.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  233.     bevelPanel6.add(phoneField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  234.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  235.     bevelPanel6.add(faxLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  236.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  237.     bevelPanel6.add(faxField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  238.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  239.     this.add(bevelPanel6, null);
  240.  
  241.  
  242.     gridLayout1.setColumns(1);
  243.     gridLayout1.setRows(6);
  244.     this.setLayout(gridLayout1);
  245.  
  246.   }
  247.  
  248.   public void setDataSet(DataSet dataSet) {
  249.     address1Field.setDataSet(dataSet);
  250.     address2Field.setDataSet(dataSet);
  251.     cityField.setDataSet(dataSet);
  252.     countryField.setDataSet(dataSet);
  253.     emailField.setDataSet(dataSet);
  254.     faxField.setDataSet(dataSet);
  255.     firstNameField.setDataSet(dataSet);
  256.     lastNameField.setDataSet(dataSet);
  257.     middleNameField.setDataSet(dataSet);
  258.     phoneField.setDataSet(dataSet);
  259.     postalCodeField.setDataSet(dataSet);
  260.     provinceField.setDataSet(dataSet);
  261.   }
  262.  
  263.   public void setReadOnly(boolean readOnly) {
  264.  
  265.     address1Field.setReadOnly(readOnly);
  266.     address2Field.setReadOnly(readOnly);
  267.     cityField.setReadOnly(readOnly);
  268.     countryField.setReadOnly(readOnly);
  269.     emailField.setReadOnly(readOnly);
  270.     faxField.setReadOnly(readOnly);
  271.     firstNameField.setReadOnly(readOnly);
  272.     lastNameField.setReadOnly(readOnly);
  273.     middleNameField.setReadOnly(readOnly);
  274.     phoneField.setReadOnly(readOnly);
  275.     postalCodeField.setReadOnly(readOnly);
  276.     provinceField.setReadOnly(readOnly);
  277.  
  278.     if (readOnly) {
  279.       address1Field.setBackground(SystemColor.control);
  280.       address2Field.setBackground(SystemColor.control);
  281.       cityField.setBackground(SystemColor.control);
  282.       countryField.setBackground(SystemColor.control);
  283.       emailField.setBackground(SystemColor.control);
  284.       faxField.setBackground(SystemColor.control);
  285.       firstNameField.setBackground(SystemColor.control);
  286.       lastNameField.setBackground(SystemColor.control);
  287.       middleNameField.setBackground(SystemColor.control);
  288.       phoneField.setBackground(SystemColor.control);
  289.       postalCodeField.setBackground(SystemColor.control);
  290.       provinceField.setBackground(SystemColor.control);
  291.     } else {
  292.       address1Field.setBackground(SystemColor.window);
  293.       address2Field.setBackground(SystemColor.window);
  294.       cityField.setBackground(SystemColor.window);
  295.       countryField.setBackground(SystemColor.window);
  296.       emailField.setBackground(SystemColor.window);
  297.       faxField.setBackground(SystemColor.window);
  298.       firstNameField.setBackground(SystemColor.window);
  299.       lastNameField.setBackground(SystemColor.window);
  300.       middleNameField.setBackground(SystemColor.window);
  301.       phoneField.setBackground(SystemColor.window);
  302.       postalCodeField.setBackground(SystemColor.window);
  303.       provinceField.setBackground(SystemColor.window);
  304.     }
  305.   }
  306.  
  307.   public void localeChanged(LocaleChangeEvent e) {
  308.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  309.     address1Label.setText(textRes.getString("address1"));
  310.     address2Label.setText(textRes.getString("address2"));
  311.     cityLabel.setText(textRes.getString("city"));
  312.     countryLabel.setText(textRes.getString("country"));
  313.     emailLabel.setText(textRes.getString("e_mail"));
  314.     faxLabel.setText(textRes.getString("fax"));
  315.     firstNameLabel.setText(textRes.getString("first_name"));
  316.     lastNameLabel.setText(textRes.getString("last_name"));
  317.     middleNameLabel.setText(textRes.getString("middle_name"));
  318.     phoneLabel.setText(textRes.getString("phone"));
  319.     postalCodeLabel.setText(textRes.getString("postal_code"));
  320.     provinceLabel.setText(textRes.getString("province"));
  321.   }
  322.  
  323. }
  324.  
  325.  
  326.  
  327.