home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / ShipToPanel.java < prev    next >
Encoding:
Java Source  |  1997-07-30  |  3.3 KB  |  91 lines

  1.  
  2. package borland.samples.intl.gui;
  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.  
  10. import borland.samples.intl.application.*;
  11. import borland.samples.intl.beans.event.*;
  12.  
  13. public class ShipToPanel extends BevelPanel implements LocaleChangeListener {
  14.   private AppDataModule appDataModule = AppDataModule.getDataModule();
  15.  
  16.   BevelPanel bevelPanel1 = new BevelPanel();
  17.   BorderLayout borderLayout1 = new BorderLayout();
  18.   InterchangeableCustomerInfoPanel customerInfoPanel;
  19.   BorderLayout borderLayout2 = new BorderLayout();
  20.   CheckboxControl useSameAddressCheckbox = new CheckboxControl();
  21.   ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes");
  22.   ResourceBundle guiRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes");
  23.  
  24.   public ShipToPanel() {
  25.     try {
  26.       jbInit();
  27.     }
  28.     catch (Exception e) {
  29.       e.printStackTrace();
  30.     }
  31.   }
  32.  
  33.   public void jbInit() throws Exception{
  34.     useSameAddressCheckbox.setChecked(true);
  35.     useSameAddressCheckbox.setLabel(textRes.getString("Use_same_address"));
  36.     useSameAddressCheckbox.addItemListener(new ShipToPanel_useSameAddressCheckbox_itemListenerAdapter(this));
  37.     this.setLayout(borderLayout1);
  38.     this.add(useSameAddressCheckbox, BorderLayout.NORTH);
  39.     customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("ShipToCustomerInfoPanel");
  40.     this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
  41.  
  42.     customerInfoPanel.setReadOnly(true);
  43.     customerInfoPanel.setDataSet(appDataModule.getCustomerDataSet());
  44.     LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
  45.   }
  46.  
  47.   void useSameAddressCheckbox_itemStateChanged(ItemEvent e) {
  48.     if (useSameAddressCheckbox.isChecked()) {
  49.        customerInfoPanel.setReadOnly(true);
  50.        customerInfoPanel.setDataSet(appDataModule.getCustomerDataSet());
  51.     } else {
  52.        customerInfoPanel.setReadOnly(false);
  53.        customerInfoPanel.setDataSet(appDataModule.getOrderDataSet());
  54.     }
  55.   }
  56.  
  57.   public void localeChanged(LocaleChangeEvent e) {
  58.     textRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes", e.getLocale());
  59.     guiRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes", e.getLocale());
  60.     useSameAddressCheckbox.setLabel(textRes.getString("Use_same_address"));
  61.     this.remove((Panel) customerInfoPanel);
  62.     customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("ShipToCustomerInfoPanel");
  63.     this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
  64.     if (useSameAddressCheckbox.isChecked()) {
  65.        customerInfoPanel.setReadOnly(true);
  66.        customerInfoPanel.setDataSet(appDataModule.getCustomerDataSet());
  67.     } else {
  68.        customerInfoPanel.setReadOnly(false);
  69.        customerInfoPanel.setDataSet(appDataModule.getOrderDataSet());
  70.     }
  71.   }
  72.  
  73. }
  74.  
  75. class ShipToPanel_useSameAddressCheckbox_itemListenerAdapter implements java.awt.event.ItemListener {
  76.   ShipToPanel adaptee;
  77.  
  78.   ShipToPanel_useSameAddressCheckbox_itemListenerAdapter(ShipToPanel adaptee) {
  79.     this.adaptee = adaptee;
  80.   }
  81.  
  82.   public void itemStateChanged(ItemEvent e) {
  83.     adaptee.useSameAddressCheckbox_itemStateChanged(e);
  84.   }
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.