home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / CustomerInfoPanel_zh_TW.java < prev    next >
Text File  |  1998-05-08  |  13KB  |  288 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20.  
  21. package borland.samples.intl.gui.resources;
  22.  
  23. import java.awt.*;
  24. import java.awt.event.*;
  25. import java.util.*;
  26. import borland.jbcl.layout.*;
  27. import borland.jbcl.control.*;
  28. import borland.jbcl.dataset.*;
  29.  
  30. import borland.samples.intl.application.*;
  31. import borland.samples.intl.beans.*;
  32. import borland.samples.intl.beans.event.*;
  33. import borland.samples.intl.gui.*;
  34.  
  35.  
  36. /**
  37.  * CustomerInfoPanel for Chinese (Taiwan) address format.
  38.  */
  39. public class CustomerInfoPanel_zh_TW extends Panel implements InterchangeableCustomerInfoPanel {
  40.   AppDataModule appDataModule = AppDataModule.getDataModule();
  41.  
  42.   FieldControl address1Field = new FieldControl();
  43.   FieldControl address2Field = new FieldControl();
  44.   FieldControl cityField = new FieldControl();
  45.   FieldControl countryField = new FieldControl();
  46.   FieldControl emailField = new FieldControl();
  47.   FieldControl faxField = new FieldControl();
  48.   FieldControl firstNameField = new FieldControl();
  49.   FieldControl lastNameField = new FieldControl();
  50.   FieldControl middleNameField = new FieldControl();
  51.   FieldControl phoneField = new FieldControl();
  52.   FieldControl postalCodeField = new FieldControl();
  53.   FieldControl provinceField = new FieldControl();
  54.  
  55.   LabelControl address1Label = new LabelControl();
  56.   LabelControl address2Label = new LabelControl();
  57.   LabelControl cityLabel = new LabelControl();
  58.   LabelControl countryLabel = new LabelControl();
  59.   LabelControl emailLabel = new LabelControl();
  60.   LabelControl faxLabel = new LabelControl();
  61.   LabelControl firstNameLabel = new LabelControl();
  62.   LabelControl lastNameLabel = new LabelControl();
  63.   LabelControl middleNameLabel = new LabelControl();
  64.   LabelControl phoneLabel = new LabelControl();
  65.   LabelControl postalCodeLabel = new LabelControl();
  66.   LabelControl provinceLabel = new LabelControl();
  67.  
  68.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  69.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  70.   GridBagLayout gridBagLayout3 = new GridBagLayout();
  71.   GridBagLayout gridBagLayout4 = new GridBagLayout();
  72.   GridBagLayout gridBagLayout5 = new GridBagLayout();
  73.   GridBagLayout gridBagLayout6 = new GridBagLayout();
  74.  
  75.   BevelPanel bevelPanel1 = new BevelPanel();                   
  76.   BevelPanel bevelPanel2 = new BevelPanel();
  77.   BevelPanel bevelPanel3 = new BevelPanel();
  78.   BevelPanel bevelPanel4 = new BevelPanel();
  79.   BevelPanel bevelPanel5 = new BevelPanel();
  80.   BevelPanel bevelPanel6 = new BevelPanel();
  81.  
  82.   GridLayout gridLayout1 = new GridLayout();
  83.  
  84.   ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes",
  85.                                                               LocaleChangeManager.getLocale());
  86.  
  87.   public CustomerInfoPanel_zh_TW() {
  88.     try {
  89.       jbInit();
  90.     }
  91.     catch (Exception e) {
  92.       e.printStackTrace();
  93.     }
  94.   }
  95.  
  96.   public void jbInit() throws Exception{
  97.  
  98.     lastNameLabel.setAlignment(Label.RIGHT);
  99.     lastNameLabel.setText(textRes.getString("last_name"));
  100.  
  101.     lastNameField.setColumnName("last_name");
  102.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  103.  
  104.     firstNameLabel.setAlignment(Label.RIGHT);
  105.     firstNameLabel.setText(textRes.getString("first_name"));
  106.  
  107.     firstNameField.setColumnName("first_name");
  108.     firstNameField.setDataSet(appDataModule.getCustomerDataSet());
  109.  
  110.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  111.     bevelPanel1.setLayout(gridBagLayout1);
  112.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  113.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  114.     bevelPanel1.add(lastNameField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  115.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  116.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  117.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  118.     bevelPanel1.add(firstNameField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  119.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  120.     this.add(bevelPanel1, null);
  121.  
  122.     address1Label.setAlignment(Label.RIGHT);
  123.     address1Label.setText(textRes.getString("address1"));
  124.  
  125.     address1Field.setColumnName("address1");
  126.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  127.  
  128.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  129.     bevelPanel2.setLayout(gridBagLayout2);
  130.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  131.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  132.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  133.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  134.     this.add(bevelPanel2, null);
  135.  
  136.     cityLabel.setAlignment(Label.RIGHT);
  137.     cityLabel.setText(textRes.getString("city"));
  138.  
  139.     cityField.setColumnName("city");
  140.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  141.  
  142.     countryLabel.setAlignment(Label.RIGHT);
  143.     countryLabel.setText(textRes.getString("country"));
  144.  
  145.     countryField.setColumnName("country");
  146.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  147.  
  148.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  149.     bevelPanel3.setLayout(gridBagLayout3);
  150.     bevelPanel3.add(cityLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  151.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  152.     bevelPanel3.add(cityField, new GridBagConstraints2(1, 0, 5, 1, 50.0, 0.0
  153.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  154.     bevelPanel3.add(countryLabel, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
  155.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  156.     bevelPanel3.add(countryField, new GridBagConstraints2(7, 0, 5, 1, 50.0, 0.0
  157.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  158.     this.add(bevelPanel3, null);
  159.  
  160.     phoneLabel.setAlignment(Label.RIGHT);
  161.     phoneLabel.setText(textRes.getString("phone"));
  162.  
  163.     phoneField.setColumnName("phone");
  164.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  165.  
  166.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  167.     bevelPanel4.setLayout(gridBagLayout4);
  168.     bevelPanel4.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  169.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  170.     bevelPanel4.add(phoneField, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  171.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  172.     this.add(bevelPanel4, null);
  173.  
  174.     faxLabel.setAlignment(Label.RIGHT);
  175.     faxLabel.setText(textRes.getString("fax"));
  176.  
  177.     faxField.setColumnName("fax");
  178.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  179.  
  180.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  181.     bevelPanel5.setLayout(gridBagLayout6);
  182.     bevelPanel5.add(faxLabel, new GridBagConstraints2(1, 0, 1, 1, 0.0, 0.0
  183.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  184.     bevelPanel5.add(faxField, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  185.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  186.     this.add(bevelPanel5, null);
  187.  
  188.     emailLabel.setAlignment(Label.RIGHT);
  189.     emailLabel.setText(textRes.getString("e_mail"));
  190.  
  191.     emailField.setColumnName("e_mail");
  192.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  193.  
  194.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  195.     bevelPanel6.setLayout(gridBagLayout5);
  196.     bevelPanel6.add(emailLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  197.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  198.     bevelPanel6.add(emailField, new GridBagConstraints2(1, 0, 11, 1, 100.0, 0.0
  199.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  200.     this.add(bevelPanel6, null);
  201.  
  202.  
  203.     gridLayout1.setColumns(1);
  204.     gridLayout1.setRows(6);
  205.     this.setLayout(gridLayout1);
  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.  
  288.