home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel.java < prev    next >
Text File  |  1997-07-24  |  14KB  |  308 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. /**
  16.  * CustomerInfoPanel for United States address format.
  17.  */
  18. public class CustomerInfoPanel 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() {   
  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.     middleNameLabel.setAlignment(Label.RIGHT);
  83.     middleNameLabel.setText(textRes.getString("middle_name"));
  84.  
  85.     middleNameField.setColumnName("middle_name");
  86.     middleNameField.setDataSet(appDataModule.getCustomerDataSet());
  87.  
  88.     lastNameLabel.setAlignment(Label.RIGHT);
  89.     lastNameLabel.setText(textRes.getString("last_name"));
  90.  
  91.     lastNameField.setColumnName("last_name");
  92.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  93.  
  94.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  95.     bevelPanel1.setLayout(gridBagLayout1);
  96.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  97.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  98.     bevelPanel1.add(firstNameField, new GridBagConstraints2(1, 0, 3, 1, 45.0, 0.0
  99.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  100.     bevelPanel1.add(middleNameLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  101.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  102.     bevelPanel1.add(middleNameField, new GridBagConstraints2(5, 0, 3, 1, 10.0, 0.0
  103.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  104.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  105.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  106.     bevelPanel1.add(lastNameField, new GridBagConstraints2(9, 0, 3, 1, 45.0, 0.0
  107.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  108.     this.add(bevelPanel1, null);
  109.  
  110.     address1Label.setAlignment(Label.RIGHT);
  111.     address1Label.setText(textRes.getString("address1"));
  112.  
  113.     address1Field.setColumnName("address1");
  114.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  115.  
  116.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  117.     bevelPanel2.setLayout(gridBagLayout2);
  118.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  119.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  120.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  121.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  122.     this.add(bevelPanel2, null);
  123.  
  124.     address2Label.setAlignment(Label.RIGHT);
  125.     address2Label.setText(textRes.getString("address2"));
  126.  
  127.     address2Field.setColumnName("address2");
  128.     address2Field.setDataSet(appDataModule.getCustomerDataSet());
  129.  
  130.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  131.     bevelPanel3.setLayout(gridBagLayout3);
  132.     bevelPanel3.add(address2Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  133.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  134.     bevelPanel3.add(address2Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  135.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  136.     this.add(bevelPanel3, null);
  137.  
  138.     cityLabel.setAlignment(Label.RIGHT);
  139.     cityLabel.setText(textRes.getString("city"));
  140.  
  141.     cityField.setColumnName("city");
  142.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  143.  
  144.     provinceLabel.setAlignment(Label.RIGHT);
  145.     provinceLabel.setText(textRes.getString("province"));
  146.  
  147.     provinceField.setColumnName("province");
  148.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  149.  
  150.     postalCodeLabel.setAlignment(Label.RIGHT);
  151.     postalCodeLabel.setText(textRes.getString("postal_code"));
  152.  
  153.     postalCodeField.setColumnName("postal_code");
  154.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  155.  
  156.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  157.     bevelPanel4.setLayout(gridBagLayout4);
  158.     bevelPanel4.add(cityLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  159.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  160.     bevelPanel4.add(cityField, new GridBagConstraints2(1, 0, 3, 1, 80.0, 0.0
  161.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  162.     bevelPanel4.add(provinceLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  163.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  164.     bevelPanel4.add(provinceField, new GridBagConstraints2(5, 0, 3, 1, 10.0, 0.0
  165.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  166.     bevelPanel4.add(postalCodeLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  167.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  168.     bevelPanel4.add(postalCodeField, new GridBagConstraints2(9, 0, 3, 1, 10.0, 0.0
  169.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  170.     this.add(bevelPanel4, null);
  171.  
  172.     countryLabel.setAlignment(Label.RIGHT);
  173.     countryLabel.setText(textRes.getString("country"));
  174.  
  175.     countryField.setColumnName("country");
  176.     countryField.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.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  185.     bevelPanel5.setLayout(gridBagLayout6);
  186.     bevelPanel5.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  187.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  188.     bevelPanel5.add(countryField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  189.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  190.     bevelPanel5.add(emailLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  191.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  192.     bevelPanel5.add(emailField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  193.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  194.     this.add(bevelPanel5, null);
  195.  
  196.     phoneLabel.setAlignment(Label.RIGHT);
  197.     phoneLabel.setText(textRes.getString("phone"));
  198.  
  199.     phoneField.setColumnName("phone");
  200.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  201.  
  202.     faxLabel.setAlignment(Label.RIGHT);
  203.     faxLabel.setText(textRes.getString("fax"));
  204.  
  205.     faxField.setColumnName("fax");
  206.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  207.  
  208.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  209.     bevelPanel6.setLayout(gridBagLayout5);
  210.     bevelPanel6.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  211.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  212.     bevelPanel6.add(phoneField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  213.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  214.     bevelPanel6.add(faxLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  215.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  216.     bevelPanel6.add(faxField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  217.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  218.     this.add(bevelPanel6, null);
  219.  
  220.  
  221.     gridLayout1.setColumns(1);
  222.     gridLayout1.setRows(6);
  223.     this.setLayout(gridLayout1);
  224.  
  225.     LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
  226.  
  227.   }
  228.  
  229.   public void setDataSet(DataSet dataSet) {
  230.     address1Field.setDataSet(dataSet);
  231.     address2Field.setDataSet(dataSet);
  232.     cityField.setDataSet(dataSet);
  233.     countryField.setDataSet(dataSet);
  234.     emailField.setDataSet(dataSet);
  235.     faxField.setDataSet(dataSet);
  236.     firstNameField.setDataSet(dataSet);
  237.     lastNameField.setDataSet(dataSet);
  238.     middleNameField.setDataSet(dataSet);
  239.     phoneField.setDataSet(dataSet);
  240.     postalCodeField.setDataSet(dataSet);
  241.     provinceField.setDataSet(dataSet);
  242.   }
  243.  
  244.   public void setReadOnly(boolean readOnly) {
  245.  
  246.     address1Field.setReadOnly(readOnly);
  247.     address2Field.setReadOnly(readOnly);
  248.     cityField.setReadOnly(readOnly);
  249.     countryField.setReadOnly(readOnly);
  250.     emailField.setReadOnly(readOnly);
  251.     faxField.setReadOnly(readOnly);
  252.     firstNameField.setReadOnly(readOnly);
  253.     lastNameField.setReadOnly(readOnly);
  254.     middleNameField.setReadOnly(readOnly);
  255.     phoneField.setReadOnly(readOnly);
  256.     postalCodeField.setReadOnly(readOnly);
  257.     provinceField.setReadOnly(readOnly);
  258.  
  259.     if (readOnly) {
  260.       address1Field.setBackground(SystemColor.control);
  261.       address2Field.setBackground(SystemColor.control);
  262.       cityField.setBackground(SystemColor.control);
  263.       countryField.setBackground(SystemColor.control);
  264.       emailField.setBackground(SystemColor.control);
  265.       faxField.setBackground(SystemColor.control);
  266.       firstNameField.setBackground(SystemColor.control);
  267.       lastNameField.setBackground(SystemColor.control);
  268.       middleNameField.setBackground(SystemColor.control);
  269.       phoneField.setBackground(SystemColor.control);
  270.       postalCodeField.setBackground(SystemColor.control);
  271.       provinceField.setBackground(SystemColor.control);
  272.     } else {
  273.       address1Field.setBackground(SystemColor.window);
  274.       address2Field.setBackground(SystemColor.window);
  275.       cityField.setBackground(SystemColor.window);
  276.       countryField.setBackground(SystemColor.window);
  277.       emailField.setBackground(SystemColor.window);
  278.       faxField.setBackground(SystemColor.window);
  279.       firstNameField.setBackground(SystemColor.window);
  280.       lastNameField.setBackground(SystemColor.window);
  281.       middleNameField.setBackground(SystemColor.window);
  282.       phoneField.setBackground(SystemColor.window);
  283.       postalCodeField.setBackground(SystemColor.window);
  284.       provinceField.setBackground(SystemColor.window);
  285.     }
  286.   }
  287.  
  288.   public void localeChanged(LocaleChangeEvent e) {
  289.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  290.     address1Label.setText(textRes.getString("address1"));
  291.     address2Label.setText(textRes.getString("address2"));
  292.     cityLabel.setText(textRes.getString("city"));
  293.     countryLabel.setText(textRes.getString("country"));
  294.     emailLabel.setText(textRes.getString("e_mail"));
  295.     faxLabel.setText(textRes.getString("fax"));
  296.     firstNameLabel.setText(textRes.getString("first_name"));
  297.     lastNameLabel.setText(textRes.getString("last_name"));
  298.     middleNameLabel.setText(textRes.getString("middle_name"));
  299.     phoneLabel.setText(textRes.getString("phone"));
  300.     postalCodeLabel.setText(textRes.getString("postal_code"));
  301.     provinceLabel.setText(textRes.getString("province"));
  302.   }
  303.  
  304. }
  305.  
  306.  
  307.  
  308.