home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel_it.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 Italian (Italy) address format.
  18.  */
  19. public class CustomerInfoPanel_it 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_it() {
  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.     lastNameLabel.setAlignment(Label.RIGHT);
  84.     lastNameLabel.setText(textRes.getString("last_name"));
  85.  
  86.     lastNameField.setColumnName("last_name");
  87.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  88.  
  89.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  90.     bevelPanel1.setLayout(gridBagLayout1);
  91.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  92.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  93.     bevelPanel1.add(firstNameField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  94.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  95.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  96.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  97.     bevelPanel1.add(lastNameField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  98.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  99.     this.add(bevelPanel1, null);
  100.  
  101.     address1Label.setAlignment(Label.RIGHT);
  102.     address1Label.setText(textRes.getString("address1"));
  103.  
  104.     address1Field.setColumnName("address1");
  105.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  106.  
  107.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  108.     bevelPanel2.setLayout(gridBagLayout2);
  109.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  110.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  111.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  112.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  113.     this.add(bevelPanel2, null);
  114.  
  115.     postalCodeLabel.setAlignment(Label.RIGHT);
  116.     postalCodeLabel.setText(textRes.getString("postal_code"));
  117.  
  118.     postalCodeField.setColumnName("postal_code");
  119.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  120.  
  121.     cityLabel.setAlignment(Label.RIGHT);
  122.     cityLabel.setText(textRes.getString("city"));
  123.  
  124.     cityField.setColumnName("city");
  125.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  126.  
  127.     provinceLabel.setAlignment(Label.RIGHT);
  128.     provinceLabel.setText(textRes.getString("province"));
  129.  
  130.     provinceField.setColumnName("province");
  131.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  132.  
  133.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  134.     bevelPanel3.setLayout(gridBagLayout3);
  135.     bevelPanel3.add(postalCodeLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  136.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  137.     bevelPanel3.add(postalCodeField, new GridBagConstraints2(1, 0, 3, 1, 10.0, 0.0
  138.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  139.     bevelPanel3.add(cityLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  140.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  141.     bevelPanel3.add(cityField, new GridBagConstraints2(5, 0, 3, 1, 45.0, 0.0
  142.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  143.     bevelPanel3.add(provinceLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  144.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  145.     bevelPanel3.add(provinceField, new GridBagConstraints2(9, 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, 11, 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, 5, 1, 50.0, 0.0
  180.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  181.     bevelPanel5.add(faxLabel, new GridBagConstraints2(6, 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(7, 0, 5, 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, 11, 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.