home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 5.9 KB | 140 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
-
- package borland.samples.intl.gui;
-
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
-
- import borland.samples.intl.application.*;
- import borland.samples.intl.beans.*;
- import borland.samples.intl.beans.event.*;
-
- public class SoldToPanel extends BevelPanel implements LocaleChangeListener {
- private AppDataModule appDataModule = AppDataModule.getDataModule();
-
- LabelControl customerNoLabel = new LabelControl();
- LabelControl customerNoField = new LabelControl();
- BevelPanel customerNoPanel = new BevelPanel();
- BorderLayout borderLayout1 = new BorderLayout();
- InterchangeableCustomerInfoPanel customerInfoPanel;
- ButtonControl lookupCustomerButton = new ButtonControl();
- GridBagLayout gridBagLayout1 = new GridBagLayout();
- GridBagLayout gridBagLayout2 = new GridBagLayout();
- ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes",
- LocaleChangeManager.getLocale());
- ResourceBundle guiRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes",
- LocaleChangeManager.getLocale());
-
- public SoldToPanel() {
- try {
- // customerInfoPanel is loaded at runtime, so we can't design it using
- // the designer. But we get it and set its properties here so it can
- // be added to the panel in jbInit()
- customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("SoldToCustomerInfoPanel");
- customerInfoPanel.localeChanged(new LocaleChangeEvent(this, LocaleChangeManager.getLocale()));
- jbInit();
- LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void jbInit() throws Exception{
- lookupCustomerButton.setLabel(textRes.getString("Find_customer"));
- lookupCustomerButton.addActionListener(new SoldToPanel_lookupCustomerButton_actionAdapter(this));
- customerNoLabel.setText(textRes.getString("Customer_No"));
- customerNoLabel.setAlignment(Label.RIGHT);
- customerNoField.setDataSet(appDataModule.getCustomerDataSet());
- customerNoField.setColumnName("customer_no");
- customerNoField.setAlignment(Label.RIGHT);
- customerNoPanel.setLayout(gridBagLayout2);
- customerNoPanel.setBevelInner(BevelPanel.FLAT);
- customerNoPanel.add(customerNoLabel, null);
- customerNoPanel.add(customerNoField, null);
- customerNoPanel.add(lookupCustomerButton, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- customerNoPanel.add(customerNoLabel, new GridBagConstraints2(1, 0, 3, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- customerNoPanel.add(customerNoField, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
- this.setLayout(borderLayout1);
-
- this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
- this.add(customerNoPanel, BorderLayout.NORTH);
-
- }
-
-
- void lookupCustomerButton_actionPerformed(ActionEvent e) {
- try {
- Component component = this;
- Frame frame = null;
-
- while ((component = component.getParent()) != null) {
- if (component instanceof Frame) {
- frame = (Frame) component;
- break;
- }
- }
-
- if (frame == null) {
- frame = new Frame();
- }
- CustomerLookupDialog customerLookupDialog = new CustomerLookupDialog(frame, true);
- customerLookupDialog.show();
- if (customerLookupDialog.isValidCustomer()) {
- appDataModule.syncCustomerNoWithCurrentOrder();
- }
- } catch (Exception ex) {
- borland.jbcl.util.Diagnostic.printStackTrace(ex);
- }
-
- }
-
- public void localeChanged(LocaleChangeEvent e) {
- textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes", e.getLocale());
- guiRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes", e.getLocale());
- customerNoLabel.setText(textRes.getString("Customer_No"));
- lookupCustomerButton.setLabel(textRes.getString("Find_customer"));
- this.remove((Panel) customerInfoPanel);
- customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("SoldToCustomerInfoPanel");
- customerInfoPanel.localeChanged(e);
- this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
- }
-
- }
-
- class SoldToPanel_lookupCustomerButton_actionAdapter implements java.awt.event.ActionListener{
- SoldToPanel adaptee;
-
- SoldToPanel_lookupCustomerButton_actionAdapter(SoldToPanel adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.lookupCustomerButton_actionPerformed(e);
- }
- }
-