home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel_en_CA.java < prev    next >
Text File  |  1997-07-24  |  13KB  |  284 lines

  1. package borland.samples.intl.gui.resources;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.util.*;
  6. import borland.jbcl.layout.*;
  7. import borland.jbcl.control.*;
  8. import borland.jbcl.dataset.*;
  9.  
  10. import borland.samples.intl.application.*;
  11. import borland.samples.intl.beans.event.*;
  12. import borland.samples.intl.gui.*;
  13.  
  14. /**
  15.  * CustomerInfoPanel for English Canadian address format.
  16.  */
  17. public class CustomerInfoPanel_en_CA extends BevelPanel implements InterchangeableCustomerInfoPanel, LocaleChangeListener {
  18.   AppDataModule appDataModule = AppDataModule.getDataModule();
  19.  
  20.   FieldControl address1Field = new FieldControl();
  21.   FieldControl address2Field = new FieldControl();
  22.   FieldControl cityField = new FieldControl();
  23.   FieldControl countryField = new FieldControl();
  24.   FieldControl emailField = new FieldControl();
  25.   FieldControl faxField = new FieldControl();
  26.   FieldControl firstNameField = new FieldControl();
  27.   FieldControl lastNameField = new FieldControl();
  28.   FieldControl middleNameField = new FieldControl();
  29.   FieldControl phoneField = new FieldControl();
  30.   FieldControl postalCodeField = new FieldControl();
  31.   FieldControl provinceField = new FieldControl();
  32.  
  33.   LabelControl address1Label = new LabelControl();
  34.   LabelControl address2Label = new LabelControl();
  35.   LabelControl cityLabel = new LabelControl();
  36.   LabelControl countryLabel = new LabelControl();
  37.   LabelControl emailLabel = new LabelControl();
  38.   LabelControl faxLabel = new LabelControl();
  39.   LabelControl firstNameLabel = new LabelControl();
  40.   LabelControl lastNameLabel = new LabelControl();
  41.   LabelControl middleNameLabel = new LabelControl();
  42.   LabelControl phoneLabel = new LabelControl();
  43.   LabelControl postalCodeLabel = new LabelControl();
  44.   LabelControl provinceLabel = new LabelControl();
  45.  
  46.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  47.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  48.   GridBagLayout gridBagLayout3 = new GridBagLayout();
  49.   GridBagLayout gridBagLayout4 = new GridBagLayout();
  50.   GridBagLayout gridBagLayout5 = new GridBagLayout();
  51.   GridBagLayout gridBagLayout6 = new GridBagLayout();
  52.  
  53.   BevelPanel bevelPanel1 = new BevelPanel();
  54.   BevelPanel bevelPanel2 = new BevelPanel();
  55.   BevelPanel bevelPanel3 = new BevelPanel();
  56.   BevelPanel bevelPanel4 = new BevelPanel();
  57.   BevelPanel bevelPanel5 = new BevelPanel();
  58.   BevelPanel bevelPanel6 = new BevelPanel();
  59.  
  60.   GridLayout gridLayout1 = new GridLayout();
  61.  
  62.   ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes");
  63.  
  64.   public CustomerInfoPanel_en_CA() {
  65.     try {
  66.       jbInit();
  67.     }
  68.     catch (Exception e) {
  69.       e.printStackTrace();
  70.     }
  71.   }
  72.  
  73.   public void jbInit() throws Exception{
  74.  
  75.     firstNameLabel.setAlignment(Label.RIGHT);
  76.     firstNameLabel.setText(textRes.getString("first_name"));
  77.  
  78.     firstNameField.setColumnName("first_name");
  79.     firstNameField.setDataSet(appDataModule.getCustomerDataSet());
  80.  
  81.     lastNameLabel.setAlignment(Label.RIGHT);
  82.     lastNameLabel.setText(textRes.getString("last_name"));
  83.  
  84.     lastNameField.setColumnName("last_name");
  85.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  86.  
  87.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  88.     bevelPanel1.setLayout(gridBagLayout1);
  89.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  90.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  91.     bevelPanel1.add(firstNameField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  92.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  93.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  94.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  95.     bevelPanel1.add(lastNameField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  96.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  97.     this.add(bevelPanel1, null);
  98.  
  99.     address1Label.setAlignment(Label.RIGHT);
  100.     address1Label.setText(textRes.getString("address1"));
  101.  
  102.     address1Field.setColumnName("address1");
  103.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  104.  
  105.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  106.     bevelPanel2.setLayout(gridBagLayout2);
  107.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  108.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  109.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  110.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  111.     this.add(bevelPanel2, null);
  112.  
  113.     cityLabel.setAlignment(Label.RIGHT);
  114.     cityLabel.setText(textRes.getString("city"));
  115.  
  116.     cityField.setColumnName("city");
  117.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  118.  
  119.     provinceLabel.setAlignment(Label.RIGHT);
  120.     provinceLabel.setText(textRes.getString("province"));
  121.  
  122.     provinceField.setColumnName("province");
  123.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  124.  
  125.     postalCodeLabel.setAlignment(Label.RIGHT);
  126.     postalCodeLabel.setText(textRes.getString("postal_code"));
  127.  
  128.     postalCodeField.setColumnName("postal_code");
  129.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  130.  
  131.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  132.     bevelPanel3.setLayout(gridBagLayout3);
  133.     bevelPanel3.add(cityLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  134.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  135.     bevelPanel3.add(cityField, new GridBagConstraints2(1, 0, 3, 1, 45.0, 0.0
  136.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  137.     bevelPanel3.add(provinceLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  138.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  139.     bevelPanel3.add(provinceField, new GridBagConstraints2(5, 0, 3, 1, 45.0, 0.0
  140.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  141.     bevelPanel3.add(postalCodeLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  142.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  143.     bevelPanel3.add(postalCodeField, new GridBagConstraints2(9, 0, 2, 1, 10.0, 0.0
  144.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  145.     this.add(bevelPanel3, null);
  146.  
  147.     countryLabel.setAlignment(Label.RIGHT);
  148.     countryLabel.setText(textRes.getString("country"));
  149.  
  150.     countryField.setColumnName("country");
  151.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  152.  
  153.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  154.     bevelPanel4.setLayout(gridBagLayout4);
  155.     bevelPanel4.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  156.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  157.     bevelPanel4.add(countryField, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  158.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  159.     this.add(bevelPanel4, null);
  160.  
  161.     phoneLabel.setAlignment(Label.RIGHT);
  162.     phoneLabel.setText(textRes.getString("phone"));
  163.  
  164.     phoneField.setColumnName("phone");
  165.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  166.  
  167.     faxLabel.setAlignment(Label.RIGHT);
  168.     faxLabel.setText(textRes.getString("fax"));
  169.  
  170.     faxField.setColumnName("fax");
  171.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  172.  
  173.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  174.     bevelPanel5.setLayout(gridBagLayout5);
  175.     bevelPanel5.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  176.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  177.     bevelPanel5.add(phoneField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  178.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  179.     bevelPanel5.add(faxLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  180.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  181.     bevelPanel5.add(faxField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  182.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  183.     this.add(bevelPanel5, null);
  184.  
  185.     emailLabel.setAlignment(Label.RIGHT);
  186.     emailLabel.setText(textRes.getString("e_mail"));
  187.  
  188.     emailField.setColumnName("e_mail");
  189.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  190.  
  191.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  192.     bevelPanel6.setLayout(gridBagLayout6);
  193.     bevelPanel6.add(emailLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  194.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  195.     bevelPanel6.add(emailField, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  196.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  197.     this.add(bevelPanel6, null);
  198.  
  199.     gridLayout1.setRows(6);
  200.     gridLayout1.setColumns(1);
  201.     this.setLayout(gridLayout1);
  202.  
  203.     LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
  204.   }
  205.  
  206.   public void setDataSet(DataSet dataSet) {
  207.     address1Field.setDataSet(dataSet);
  208.     address2Field.setDataSet(dataSet);
  209.     cityField.setDataSet(dataSet);
  210.     countryField.setDataSet(dataSet);
  211.     emailField.setDataSet(dataSet);
  212.     faxField.setDataSet(dataSet);
  213.     firstNameField.setDataSet(dataSet);
  214.     lastNameField.setDataSet(dataSet);
  215.     middleNameField.setDataSet(dataSet);
  216.     phoneField.setDataSet(dataSet);
  217.     postalCodeField.setDataSet(dataSet);
  218.     provinceField.setDataSet(dataSet);
  219.   }
  220.  
  221.   public void setReadOnly(boolean readOnly) {
  222.  
  223.     address1Field.setReadOnly(readOnly);
  224.     address2Field.setReadOnly(readOnly);
  225.     cityField.setReadOnly(readOnly);
  226.     countryField.setReadOnly(readOnly);
  227.     emailField.setReadOnly(readOnly);
  228.     faxField.setReadOnly(readOnly);
  229.     firstNameField.setReadOnly(readOnly);
  230.     lastNameField.setReadOnly(readOnly);
  231.     middleNameField.setReadOnly(readOnly);
  232.     phoneField.setReadOnly(readOnly);
  233.     postalCodeField.setReadOnly(readOnly);
  234.     provinceField.setReadOnly(readOnly);
  235.  
  236.     if (readOnly) {
  237.       address1Field.setBackground(SystemColor.control);
  238.       address2Field.setBackground(SystemColor.control);
  239.       cityField.setBackground(SystemColor.control);
  240.       countryField.setBackground(SystemColor.control);
  241.       emailField.setBackground(SystemColor.control);
  242.       faxField.setBackground(SystemColor.control);
  243.       firstNameField.setBackground(SystemColor.control);
  244.       lastNameField.setBackground(SystemColor.control);
  245.       middleNameField.setBackground(SystemColor.control);
  246.       phoneField.setBackground(SystemColor.control);
  247.       postalCodeField.setBackground(SystemColor.control);
  248.       provinceField.setBackground(SystemColor.control);
  249.     } else {
  250.       address1Field.setBackground(SystemColor.window);
  251.       address2Field.setBackground(SystemColor.window);
  252.       cityField.setBackground(SystemColor.window);
  253.       countryField.setBackground(SystemColor.window);
  254.       emailField.setBackground(SystemColor.window);
  255.       faxField.setBackground(SystemColor.window);
  256.       firstNameField.setBackground(SystemColor.window);
  257.       lastNameField.setBackground(SystemColor.window);
  258.       middleNameField.setBackground(SystemColor.window);
  259.       phoneField.setBackground(SystemColor.window);
  260.       postalCodeField.setBackground(SystemColor.window);
  261.       provinceField.setBackground(SystemColor.window);
  262.     }
  263.   }
  264.  
  265.   public void localeChanged(LocaleChangeEvent e) {
  266.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  267.     address1Label.setText(textRes.getString("address1"));
  268.     address2Label.setText(textRes.getString("address2"));
  269.     cityLabel.setText(textRes.getString("city"));
  270.     countryLabel.setText(textRes.getString("country"));
  271.     emailLabel.setText(textRes.getString("e_mail"));
  272.     faxLabel.setText(textRes.getString("fax"));
  273.     firstNameLabel.setText(textRes.getString("first_name"));
  274.     lastNameLabel.setText(textRes.getString("last_name"));
  275.     middleNameLabel.setText(textRes.getString("middle_name"));
  276.     phoneLabel.setText(textRes.getString("phone"));
  277.     postalCodeLabel.setText(textRes.getString("postal_code"));
  278.     provinceLabel.setText(textRes.getString("province"));
  279.   }
  280.  
  281. }
  282.  
  283.  
  284.