home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel_fr_CA.java < prev    next >
Encoding:
Java Source  |  1997-07-24  |  12.5 KB  |  285 lines

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