home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel_de_CH.java < prev    next >
Text File  |  1997-07-10  |  12KB  |  272 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 German (Switzerland) address format.
  16.  */
  17. public class CustomerInfoPanel_de_CH 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_de_CH() {
  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.     postalCodeLabel.setAlignment(Label.RIGHT);
  114.     postalCodeLabel.setText(textRes.getString("postal_code"));
  115.  
  116.     postalCodeField.setColumnName("postal_code");
  117.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  118.  
  119.     cityLabel.setAlignment(Label.RIGHT);
  120.     cityLabel.setText(textRes.getString("city"));
  121.  
  122.     cityField.setColumnName("city");
  123.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  124.  
  125.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  126.     bevelPanel3.setLayout(gridBagLayout3);
  127.     bevelPanel3.add(postalCodeLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  128.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  129.     bevelPanel3.add(postalCodeField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  130.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  131.     bevelPanel3.add(cityLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  132.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  133.     bevelPanel3.add(cityField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  134.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  135.     this.add(bevelPanel3, null);
  136.  
  137.     countryLabel.setAlignment(Label.RIGHT);
  138.     countryLabel.setText(textRes.getString("country"));
  139.  
  140.     countryField.setColumnName("country");
  141.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  142.  
  143.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  144.     bevelPanel4.setLayout(gridBagLayout4);
  145.     bevelPanel4.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  146.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  147.     bevelPanel4.add(countryField, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  148.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  149.     this.add(bevelPanel4, null);
  150.  
  151.     phoneLabel.setAlignment(Label.RIGHT);
  152.     phoneLabel.setText(textRes.getString("phone"));
  153.  
  154.     phoneField.setColumnName("phone");
  155.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  156.  
  157.     faxLabel.setAlignment(Label.RIGHT);
  158.     faxLabel.setText(textRes.getString("fax"));
  159.  
  160.     faxField.setColumnName("fax");
  161.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  162.  
  163.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  164.     bevelPanel5.setLayout(gridBagLayout5);
  165.     bevelPanel5.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  166.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  167.     bevelPanel5.add(phoneField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  168.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  169.     bevelPanel5.add(faxLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  170.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  171.     bevelPanel5.add(faxField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  172.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  173.     this.add(bevelPanel5, null);
  174.  
  175.     emailLabel.setAlignment(Label.RIGHT);
  176.     emailLabel.setText(textRes.getString("e_mail"));
  177.  
  178.     emailField.setColumnName("e_mail");
  179.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  180.  
  181.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  182.     bevelPanel6.setLayout(gridBagLayout6);
  183.     bevelPanel6.add(emailLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  184.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  185.     bevelPanel6.add(emailField, new GridBagConstraints2(1, 0, 3, 1, 100.0, 0.0
  186.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  187.     this.add(bevelPanel6, null);
  188.  
  189.     gridLayout1.setRows(6);
  190.     gridLayout1.setColumns(1);
  191.     this.setLayout(gridLayout1);
  192.  
  193.     LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
  194.   }
  195.  
  196.   public void setDataSet(DataSet dataSet) {
  197.     address1Field.setDataSet(dataSet);
  198.     address2Field.setDataSet(dataSet);
  199.     cityField.setDataSet(dataSet);
  200.     countryField.setDataSet(dataSet);
  201.     emailField.setDataSet(dataSet);
  202.     faxField.setDataSet(dataSet);
  203.     firstNameField.setDataSet(dataSet);
  204.     lastNameField.setDataSet(dataSet);
  205.     middleNameField.setDataSet(dataSet);
  206.     phoneField.setDataSet(dataSet);
  207.     postalCodeField.setDataSet(dataSet);
  208.     provinceField.setDataSet(dataSet);
  209.   }
  210.  
  211.   public void setReadOnly(boolean readOnly) {
  212.  
  213.     address1Field.setReadOnly(readOnly);
  214.     address2Field.setReadOnly(readOnly);
  215.     cityField.setReadOnly(readOnly);
  216.     countryField.setReadOnly(readOnly);
  217.     emailField.setReadOnly(readOnly);
  218.     faxField.setReadOnly(readOnly);
  219.     firstNameField.setReadOnly(readOnly);
  220.     lastNameField.setReadOnly(readOnly);
  221.     middleNameField.setReadOnly(readOnly);
  222.     phoneField.setReadOnly(readOnly);
  223.     postalCodeField.setReadOnly(readOnly);
  224.     provinceField.setReadOnly(readOnly);
  225.  
  226.     if (readOnly) {
  227.       address1Field.setBackground(SystemColor.control);
  228.       address2Field.setBackground(SystemColor.control);
  229.       cityField.setBackground(SystemColor.control);
  230.       countryField.setBackground(SystemColor.control);
  231.       emailField.setBackground(SystemColor.control);
  232.       faxField.setBackground(SystemColor.control);
  233.       firstNameField.setBackground(SystemColor.control);
  234.       lastNameField.setBackground(SystemColor.control);
  235.       middleNameField.setBackground(SystemColor.control);
  236.       phoneField.setBackground(SystemColor.control);
  237.       postalCodeField.setBackground(SystemColor.control);
  238.       provinceField.setBackground(SystemColor.control);
  239.     } else {
  240.       address1Field.setBackground(SystemColor.window);
  241.       address2Field.setBackground(SystemColor.window);
  242.       cityField.setBackground(SystemColor.window);
  243.       countryField.setBackground(SystemColor.window);
  244.       emailField.setBackground(SystemColor.window);
  245.       faxField.setBackground(SystemColor.window);
  246.       firstNameField.setBackground(SystemColor.window);
  247.       lastNameField.setBackground(SystemColor.window);
  248.       middleNameField.setBackground(SystemColor.window);
  249.       phoneField.setBackground(SystemColor.window);
  250.       postalCodeField.setBackground(SystemColor.window);
  251.       provinceField.setBackground(SystemColor.window);
  252.     }
  253.   }
  254.  
  255.   public void localeChanged(LocaleChangeEvent e) {
  256.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  257.     address1Label.setText(textRes.getString("address1"));
  258.     address2Label.setText(textRes.getString("address2"));
  259.     cityLabel.setText(textRes.getString("city"));
  260.     countryLabel.setText(textRes.getString("country"));
  261.     emailLabel.setText(textRes.getString("e_mail"));
  262.     faxLabel.setText(textRes.getString("fax"));
  263.     firstNameLabel.setText(textRes.getString("first_name"));
  264.     lastNameLabel.setText(textRes.getString("last_name"));
  265.     middleNameLabel.setText(textRes.getString("middle_name"));
  266.     phoneLabel.setText(textRes.getString("phone"));
  267.     postalCodeLabel.setText(textRes.getString("postal_code"));
  268.     provinceLabel.setText(textRes.getString("province"));
  269.   }
  270.  
  271. }
  272.