home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 11.5 KB | 289 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.
- */
-
- //Title: Cliffhanger Order Status Tracker
- //Version:
- //Copyright: Copyright (c) 1997 Borland International, Inc.
- //Author: Application Methods, Inc.
- //Description: Cliffhanger Adventure Gear Order Status Tracking Applet
-
- package borland.reference.tracker;
-
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
- import borland.sql.dataset.*;
- import borland.jbcl.dataset.*;
- import borland.jbcl.util.Variant;
- import java.util.*;
-
- /**
- * OrderTrackApplet defines the Applet subclass and user interface. Customers
- * would use this applet in a web-browser to find information about a recent
- * order they had placed. Given an order tracking number, they can find out
- * status information, order and shipping dates, and the amount paid on the
- * order.
- * Note that this file also contains a frame wrapper that allows this Applet
- * to be run as a standalone application. Because an Applet is a subclass of
- * panel, it can simply be wrapped in a frame as shown below so that it can
- * be run as either Applet in a browser or standalone application.
- */
- public class OrderTrackApplet extends Applet {
- boolean isStandalone = false;
- private QueryDataSet qdsPOrders;
- private ParameterRow pRow;
-
- // Instantiate panels
- BevelPanel getStatusPanel = new BevelPanel();
- BevelPanel orderItemsPanel = new BevelPanel();
-
- // Instantiate layout managers for the panels
- GridBagLayout gridBagLayoutApplet = new GridBagLayout();
- GridBagLayout gridBagLayoutGSPanel = new GridBagLayout();
- GridBagLayout gridBagLayoutOIPanel = new GridBagLayout();
-
- ImageControl titleGraphic = new ImageControl();
-
- // Instantiate field controls components
- FieldControl orderNumberField = new FieldControl();
- LabelControl orderNumberLabel = new LabelControl();
- ButtonControl statusButton = new ButtonControl();
- FieldControl orderStatusField = new FieldControl();
- LabelControl orderStatusLabel = new LabelControl();
- FieldControl orderDateField = new FieldControl();
- LabelControl orderDateLabel = new LabelControl();
- LabelControl shipDateLabel = new LabelControl();
- FieldControl shipDateField = new FieldControl();
- FieldControl amountField = new FieldControl();
- LabelControl amountLabel = new LabelControl();
- ResourceBundle res = Res.getBundle("borland.reference.tracker.Res");
-
- //Get a parameter value
- public String getParameter(String key, String def) {
- return isStandalone ? System.getProperty(key, def) :
- (getParameter(key) != null ? getParameter(key) : def);
- }
-
- //Construct the applet
- public OrderTrackApplet() {
- }
-
- //Initialize the applet
- public void init() {
- try {
- // Initialize form objects
- jbInit();
- // Initialize data objects
- initData();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- //Component initialization
- private void jbInit() throws Exception{
- this.setBackground(new Color(0, 0, 74));
- this.setSize(new Dimension(414, 176));
-
- titleGraphic.setBackground(new Color(0, 0, 74));
- titleGraphic.setImageName(".\\graphics\\StatusT.gif");
-
- getStatusPanel.setBackground(new Color(0, 0, 74));
- getStatusPanel.setBevelInner(BevelPanel.FLAT);
- getStatusPanel.setMargins(new Insets(2, 2, 2, 2));
- getStatusPanel.setLayout(gridBagLayoutGSPanel);
-
- orderStatusField.setBackground(new Color(231, 231, 232));
- orderStatusField.setColumnName("Status");
- orderStatusField.setFont(new Font("Dialog", 1, 12));
- orderStatusField.setForeground(new Color(50, 45, 215));
- orderStatusField.setReadOnly(true);
- orderStatusLabel.setAlignment(Label.RIGHT);
- orderStatusLabel.setFont(new Font("Serif", 1, 12));
- orderStatusLabel.setForeground(Color.yellow);
- orderStatusLabel.setText(res.getString("Order_Status"));
-
-
- orderDateField.setColumnName("orderDate");
- orderDateField.setFont(new Font("Dialog", 1, 12));
- orderDateField.setBackground(new Color(231, 231, 232));
- orderDateField.setEnabled(false);
- orderDateField.setReadOnly(true);
- orderDateLabel.setAlignment(Label.RIGHT);
- orderDateLabel.setFont(new Font("Serif", 1, 12));
- orderDateLabel.setForeground(Color.yellow);
- orderDateLabel.setText(res.getString("Order_Date"));
-
- shipDateLabel.setAlignment(Label.RIGHT);
- shipDateLabel.setFont(new Font("Serif", 1, 12));
- shipDateLabel.setForeground(Color.yellow);
- shipDateLabel.setText(res.getString("Ship_Date"));
- shipDateField.setColumnName("shipDate");
- shipDateField.setFont(new Font("Dialog", 1, 12));
- shipDateField.setBackground(new Color(231, 231, 232));
-
-
- orderNumberLabel.setAlignment(Label.RIGHT);
- orderNumberLabel.setFont(new Font("Serif", 1, 12));
- orderNumberLabel.setForeground(Color.yellow);
- orderNumberLabel.setText(res.getString("Tracking_Number"));
- orderItemsPanel.setBackground(new Color(0, 0, 74));
- orderItemsPanel.setBevelInner(BevelPanel.FLAT);
- orderItemsPanel.setLayout(gridBagLayoutOIPanel);
-
- statusButton.setLabel(res.getString("Show_Status"));
- statusButton.addMouseListener(new OrderTrackApplet_statusButton_mouseAdapter(this));
-
- this.setLayout(gridBagLayoutApplet);
-
- this.add(getStatusPanel, new GridBagConstraints2(0, 0, 1, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 25, 24));
- getStatusPanel.add(titleGraphic, new GridBagConstraints2(0, 0, 4, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(-5, 0, 5, 0), -34, -54));
- getStatusPanel.add(orderNumberLabel, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 8, 3), -11, 4));
- getStatusPanel.add(orderNumberField, new GridBagConstraints2(1, 1, 1, 1, 1.0, 1.0
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -12, 1));
- getStatusPanel.add(statusButton, new GridBagConstraints2(2, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 24, 5));
- this.add(orderItemsPanel, new GridBagConstraints2(0, 1, 2, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 5), -4, -2));
- orderItemsPanel.add(orderStatusField, new GridBagConstraints2(1, 0, 1, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), -7, 2));
- orderItemsPanel.add(orderStatusLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), -6, 1));
- orderItemsPanel.add(orderDateField, new GridBagConstraints2(3, 0, 1, 2, 1.0, 1.0
- ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), -7, 1));
- orderItemsPanel.add(orderDateLabel, new GridBagConstraints2(2, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 9, 2));
- orderItemsPanel.add(shipDateLabel, new GridBagConstraints2(2, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 13, 0, 0), 1, -1));
- orderItemsPanel.add(shipDateField, new GridBagConstraints2(3, 2, 1, 1, 1.0, 1.0
- ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), -7, 1));
- orderItemsPanel.add(amountField, new GridBagConstraints2(1, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), -7, 2));
- orderItemsPanel.add(amountLabel, new GridBagConstraints2(0, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -6, 0));
-
-
- amountLabel.setAlignment(Label.RIGHT);
- amountLabel.setFont(new Font("Serif", 1, 12));
- amountLabel.setForeground(Color.yellow);
- amountLabel.setText(res.getString("Amount_Paid"));
- amountField.setColumnName("amtPaid");
- amountField.setBackground(new Color(231, 231, 232));
- amountField.setEditInPlace(false);
- amountField.setForeground(Color.black);
- amountField.setFont(new Font("Dialog", 1, 12));
- amountField.setReadOnly(true);
-
-
- }
-
- //Start the applet
- public void start() {
- }
-
- //Stop the applet
- public void stop() {
- }
-
- //Destroy the applet
- public void destroy() {
- }
-
- //Get Applet information
- public String getAppletInfo() {
- return "Applet Information";
- }
-
- //Get parameter info
- public String[][] getParameterInfo() {
- return null;
- }
-
- //Main method
- static public void main(String[] args) {
- OrderTrackApplet applet = new OrderTrackApplet();
- applet.isStandalone = true;
- DecoratedFrame frame = new DecoratedFrame();
- frame.add(applet, BorderLayout.CENTER);
- applet.init();
- applet.start();
- frame.pack();
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
- frame.setVisible(true);
- }
-
-
- private void initData() {
-
- // Connect to the database and retrieve data set from DataModule
- try {
- OrderTrackDataModule dataModule = OrderTrackDataModule.getDataModule();
- dataModule.dbConnect(); // Makes a connection to the database
- qdsPOrders = dataModule.getOrdersDataSet();
- pRow = dataModule.getOrderNumParameterRow();
- }
- catch (DataSetException ex) {
- ex.printStackTrace();
- }
- }
-
- void statusButton_mouseClicked(MouseEvent e) {
- try {
- // Be sure the value typed in is committed to the field
- orderNumberField.endEdit();
- // Set the ORDERTRACKNUM parameter to the value entered in the field
- pRow.setString("ORDERTRACKNUM", orderNumberField.getText());
- // Get the data for that record
- qdsPOrders.executeQuery();
-
- // Associate each result field with the dataset
- orderStatusField.setDataSet(qdsPOrders);
- orderDateField.setDataSet(qdsPOrders);
- shipDateField.setDataSet(qdsPOrders);
- amountField.setDataSet(qdsPOrders);
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- } // END class OrderTrackApplet
-
- class OrderTrackApplet_statusButton_mouseAdapter extends java.awt.event.MouseAdapter {
- OrderTrackApplet adaptee;
-
- OrderTrackApplet_statusButton_mouseAdapter(OrderTrackApplet adaptee) {
- this.adaptee = adaptee;
- }
-
- public void mouseClicked(MouseEvent e) {
- adaptee.statusButton_mouseClicked(e);
- }
- }
-
-
-