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