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