home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / CustomerInfoPanel_ja.java < prev    next >
Text File  |  1997-07-24  |  13KB  |  286 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 Japanese (Japan) address format.
  17.  */
  18. public class CustomerInfoPanel_ja 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_ja() {
  66.     try {
  67.       jbInit();
  68.     }
  69.     catch (Exception e) {
  70.       e.printStackTrace();
  71.     }
  72.   }
  73.  
  74.   public void jbInit() throws Exception{
  75.  
  76.     countryLabel.setAlignment(Label.RIGHT);
  77.     countryLabel.setText(textRes.getString("country"));
  78.  
  79.     countryField.setColumnName("country");
  80.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  81.  
  82.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  83.     bevelPanel1.setLayout(gridBagLayout1);
  84.     bevelPanel1.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  85.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  86.     bevelPanel1.add(countryField, new GridBagConstraints2(1, 0, 3, 1, 100.0, 0.0
  87.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  88.     this.add(bevelPanel1, null);
  89.  
  90.     postalCodeLabel.setAlignment(Label.RIGHT);
  91.     postalCodeLabel.setText(textRes.getString("postal_code"));
  92.  
  93.     postalCodeField.setColumnName("postal_code");
  94.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  95.  
  96.     provinceField.setColumnName("province");
  97.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  98.  
  99.     provinceLabel.setAlignment(Label.RIGHT);
  100.     provinceLabel.setText(textRes.getString("province"));
  101.  
  102.     cityLabel.setAlignment(Label.RIGHT);
  103.     cityLabel.setText(textRes.getString("city"));
  104.  
  105.     cityField.setColumnName("city");
  106.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  107.  
  108.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  109.     bevelPanel2.setLayout(gridBagLayout2);
  110.     bevelPanel2.add(postalCodeLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  111.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  112.     bevelPanel2.add(postalCodeField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  113.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  114.     bevelPanel2.add(provinceLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  115.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  116.     bevelPanel2.add(provinceField, new GridBagConstraints2(5, 0, 2, 1, 25.0, 0.0
  117.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  118.     bevelPanel2.add(cityLabel, new GridBagConstraints2(7, 0, 1, 1, 0.0, 0.0
  119.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  120.     bevelPanel2.add(cityField, new GridBagConstraints2(8, 0, 2, 1, 25.0, 0.0
  121.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  122.     this.add(bevelPanel2, null);
  123.  
  124.     address1Label.setAlignment(Label.RIGHT);
  125.     address1Label.setText(textRes.getString("address1"));
  126.  
  127.     address1Field.setColumnName("address1");
  128.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  129.  
  130.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  131.     bevelPanel3.setLayout(gridBagLayout3);
  132.     bevelPanel3.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  133.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  134.     bevelPanel3.add(address1Field, new GridBagConstraints2(1, 0, 5, 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.     lastNameLabel.setAlignment(Label.RIGHT);
  139.     lastNameLabel.setText(textRes.getString("last_name"));
  140.  
  141.     lastNameField.setColumnName("last_name");
  142.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  143.  
  144.     firstNameLabel.setAlignment(Label.RIGHT);
  145.     firstNameLabel.setText(textRes.getString("first_name"));
  146.  
  147.     firstNameField.setColumnName("first_name");
  148.     firstNameField.setDataSet(appDataModule.getCustomerDataSet());
  149.  
  150.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  151.     bevelPanel4.setLayout(gridBagLayout4);
  152.     bevelPanel4.add(lastNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  153.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  154.     bevelPanel4.add(lastNameField, new GridBagConstraints2(1, 0, 1, 1, 50.0, 0.0
  155.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  156.     bevelPanel4.add(firstNameLabel, new GridBagConstraints2(2, 0, 1, 1, 0.0, 0.0
  157.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  158.     bevelPanel4.add(firstNameField, new GridBagConstraints2(3, 0, 1, 1, 50.0, 0.0
  159.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  160.     this.add(bevelPanel4, null);
  161.  
  162.     phoneLabel.setAlignment(Label.RIGHT);
  163.     phoneLabel.setText(textRes.getString("phone"));
  164.  
  165.     phoneField.setColumnName("phone");
  166.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  167.  
  168.     faxLabel.setAlignment(Label.RIGHT);
  169.     faxLabel.setText(textRes.getString("fax"));
  170.  
  171.     faxField.setColumnName("fax");
  172.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  173.  
  174.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  175.     bevelPanel5.setLayout(gridBagLayout5);
  176.     bevelPanel5.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  177.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  178.     bevelPanel5.add(phoneField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  179.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  180.     bevelPanel5.add(faxLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  181.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  182.     bevelPanel5.add(faxField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  183.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  184.     this.add(bevelPanel5, null);
  185.  
  186.     emailLabel.setAlignment(Label.RIGHT);
  187.     emailLabel.setText(textRes.getString("e_mail"));
  188.  
  189.     emailField.setColumnName("e_mail");
  190.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  191.  
  192.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  193.     bevelPanel6.setLayout(gridBagLayout6);
  194.     bevelPanel6.add(emailLabel, new GridBagConstraints2(0, 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(1, 0, 1, 1, 100.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.  
  208.   public void setDataSet(DataSet dataSet) {
  209.     address1Field.setDataSet(dataSet);
  210.     address2Field.setDataSet(dataSet);
  211.     cityField.setDataSet(dataSet);
  212.     countryField.setDataSet(dataSet);
  213.     emailField.setDataSet(dataSet);
  214.     faxField.setDataSet(dataSet);
  215.     firstNameField.setDataSet(dataSet);
  216.     lastNameField.setDataSet(dataSet);
  217.     middleNameField.setDataSet(dataSet);
  218.     phoneField.setDataSet(dataSet);
  219.     postalCodeField.setDataSet(dataSet);
  220.     provinceField.setDataSet(dataSet);
  221.   }
  222.  
  223.   public void setReadOnly(boolean readOnly) {
  224.  
  225.     address1Field.setReadOnly(readOnly);
  226.     address2Field.setReadOnly(readOnly);
  227.     cityField.setReadOnly(readOnly);
  228.     countryField.setReadOnly(readOnly);
  229.     emailField.setReadOnly(readOnly);
  230.     faxField.setReadOnly(readOnly);
  231.     firstNameField.setReadOnly(readOnly);
  232.     lastNameField.setReadOnly(readOnly);
  233.     middleNameField.setReadOnly(readOnly);
  234.     phoneField.setReadOnly(readOnly);
  235.     postalCodeField.setReadOnly(readOnly);
  236.     provinceField.setReadOnly(readOnly);
  237.  
  238.     if (readOnly) {
  239.       address1Field.setBackground(SystemColor.control);
  240.       address2Field.setBackground(SystemColor.control);
  241.       cityField.setBackground(SystemColor.control);
  242.       countryField.setBackground(SystemColor.control);
  243.       emailField.setBackground(SystemColor.control);
  244.       faxField.setBackground(SystemColor.control);
  245.       firstNameField.setBackground(SystemColor.control);
  246.       lastNameField.setBackground(SystemColor.control);
  247.       middleNameField.setBackground(SystemColor.control);
  248.       phoneField.setBackground(SystemColor.control);
  249.       postalCodeField.setBackground(SystemColor.control);
  250.       provinceField.setBackground(SystemColor.control);
  251.     } else {
  252.       address1Field.setBackground(SystemColor.window);
  253.       address2Field.setBackground(SystemColor.window);
  254.       cityField.setBackground(SystemColor.window);
  255.       countryField.setBackground(SystemColor.window);
  256.       emailField.setBackground(SystemColor.window);
  257.       faxField.setBackground(SystemColor.window);
  258.       firstNameField.setBackground(SystemColor.window);
  259.       lastNameField.setBackground(SystemColor.window);
  260.       middleNameField.setBackground(SystemColor.window);
  261.       phoneField.setBackground(SystemColor.window);
  262.       postalCodeField.setBackground(SystemColor.window);
  263.       provinceField.setBackground(SystemColor.window);
  264.     }
  265.   }
  266.  
  267.   public void localeChanged(LocaleChangeEvent e) {
  268.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  269.     address1Label.setText(textRes.getString("address1"));
  270.     address2Label.setText(textRes.getString("address2"));
  271.     cityLabel.setText(textRes.getString("city"));
  272.     countryLabel.setText(textRes.getString("country"));
  273.     emailLabel.setText(textRes.getString("e_mail"));
  274.     faxLabel.setText(textRes.getString("fax"));
  275.     firstNameLabel.setText(textRes.getString("first_name"));
  276.     lastNameLabel.setText(textRes.getString("last_name"));
  277.     middleNameLabel.setText(textRes.getString("middle_name"));
  278.     phoneLabel.setText(textRes.getString("phone"));
  279.     postalCodeLabel.setText(textRes.getString("postal_code"));
  280.     provinceLabel.setText(textRes.getString("province"));
  281.   }
  282.  
  283. }
  284.  
  285.  
  286.