home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / TRIAL / JBUILDER / JVISBRKR.Z / ApplicationApprovedPanel.java < prev    next >
Encoding:
Java Source  |  1998-05-08  |  8.3 KB  |  200 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. // CORBA Reference Application
  22. // Copyright (c) 1997 by Borland International, All Rights Reserved
  23. //
  24. // Panel used to display Credit Card Iformation for approved Applicants
  25. //--------------------------------------------------------------------------------------------------
  26.  
  27. package borland.reference.creditapproval.client;
  28.  
  29. import java.awt.*;
  30. import java.text.*;
  31. import java.awt.event.*;
  32. import borland.jbcl.layout.*;
  33. import borland.jbcl.control.*;
  34. import java.util.*;
  35. import java.applet.*;
  36. import borland.reference.creditapproval.CORBAInterface.*;
  37.  
  38. /**
  39. * ApplicationApprovedPanel displays the credit card information for
  40. * approved applicants.
  41. */
  42. public class ApplicationApprovedPanel extends BevelPanel {
  43.   Label label1 = new Label();
  44.   Label label3 = new Label();
  45.   Label label4 = new Label();
  46.   Label label5 = new Label();
  47.   ImageControl imageControl1 = new ImageControl();
  48.   Label label2 = new Label();
  49.   Label label6 = new Label();
  50.   Label label7 = new Label();
  51.   ButtonControl buttonControl1 = new ButtonControl();
  52.   BevelPanel bevelPanel1 = new BevelPanel();
  53.   BevelPanel bevelPanel2 = new BevelPanel();
  54.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  55.   FlowLayout flowLayout1 = new FlowLayout();
  56.   BevelPanel bevelPanel3 = new BevelPanel();
  57.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  58.   BevelPanel bevelPanel4 = new BevelPanel();
  59.   GridBagLayout gridBagLayout3 = new GridBagLayout();
  60.   ResourceBundle res = Res.getBundle("borland.reference.creditapproval.client.Res");
  61.   CreditApprovalApplet theApplet = null;
  62.   TextField textExpirationDate = new TextField();
  63.   TextField textCreditLimit = new TextField();
  64.   TextField textCreditCardNumber = new TextField();
  65.   BorderLayout borderLayout1 = new BorderLayout();
  66.  
  67.   /**
  68.   /* Default constructor - placed here for the sake of JavaBean compliance
  69.   */
  70.   public ApplicationApprovedPanel() {
  71.     try {
  72.       jbInit();
  73.     }
  74.     catch (Exception e) {
  75.       e.printStackTrace();
  76.     }
  77.   }
  78.  
  79.   /**
  80.   *  Construct the Panel by invoking jbInit
  81.   */
  82.   public ApplicationApprovedPanel(CreditApprovalApplet creditApp) {
  83.     theApplet = creditApp;
  84.     try {
  85.       jbInit();
  86.     }
  87.     catch (Exception e) {
  88.       e.printStackTrace();
  89.     }
  90.     resetEdges();
  91.   }
  92.  
  93.   /**
  94.   *  Initialize the Panel
  95.   */
  96.   private void jbInit() throws Exception{
  97.     this.setLayout(borderLayout1);
  98.     this.setBevelInner(BevelPanel.FLAT);
  99.     textCreditCardNumber.setEditable(false);
  100.     textExpirationDate.setEditable(false);
  101.     label1.setForeground(Color.red);
  102.     label1.setFont(new Font("Dialog", 1, 18));
  103.     label1.setAlignment(1);
  104.     label1.setText(res.getString("Congratulations"));
  105.     label3.setFont(new Font("Dialog", 1, 12));
  106.     label3.setBounds(new Rectangle(10, 17, 368, 23));
  107.     label3.setAlignment(1);
  108.     label3.setText(res.getString("You_have_been"));
  109.     label4.setFont(new Font("Dialog", 1, 12));
  110.     label4.setAlignment(1);
  111.     label4.setText(res.getString("Please_make_a_note_of"));
  112.     label5.setFont(new Font("Dialog", 1, 12));
  113.     label5.setBounds(new Rectangle(0, 63, 368, 23));
  114.     label5.setAlignment(1);
  115.     label5.setText(res.getString("Apermanent_card_will"));
  116.     if (theApplet != null)
  117.       imageControl1.setImageURL( new java.net.URL(theApplet.getImageLocation() + "logo.gif"));
  118.     label2.setFont(new Font("Dialog", 1, 12));
  119.     label2.setText(res.getString("Credit_Card_Number") + ":");
  120.     label6.setFont(new Font("Dialog", 1, 12));
  121.     label6.setText(res.getString("Expiration_Date") + ":");
  122.     label7.setFont(new Font("Dialog", 1, 12));
  123.     label7.setText(res.getString("Credit_Limit") + ":");
  124.     textCreditLimit.setEditable(false);
  125.     buttonControl1.setLabel(res.getString("OK"));
  126.     bevelPanel4.setLayout(gridBagLayout3);
  127.     bevelPanel3.setLayout(gridBagLayout2);
  128.     bevelPanel1.setLayout(flowLayout1);
  129.     bevelPanel2.setLayout(gridBagLayout1);
  130.     buttonControl1.addActionListener(new ApplicationApprovedPanel_buttonControl1_actionAdapter(this));
  131.     bevelPanel1.add(imageControl1, null);
  132.     this.add(bevelPanel1, BorderLayout.EAST);
  133.     bevelPanel2.add(buttonControl1, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  134.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 0, 4, 0), 33, 0));
  135.     this.add(bevelPanel2, BorderLayout.SOUTH);
  136.     this.add(bevelPanel3, BorderLayout.NORTH);
  137.     bevelPanel3.add(label1, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  138.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  139.     this.add(bevelPanel4, BorderLayout.CENTER);
  140.     bevelPanel4.add(label7, new GridBagConstraints2(0, 5, 1, 1, 0.0, 1.0
  141.             ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 24, 0, 0), 45, 0));
  142.     bevelPanel4.add(textCreditLimit, new GridBagConstraints2(1, 5, 1, 1, 0.0, 1.0
  143.             ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 54, 0));
  144.     bevelPanel4.add(textExpirationDate, new GridBagConstraints2(1, 4, 1, 1, 0.0, 0.0
  145.             ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 54, 0));
  146.     bevelPanel4.add(label6, new GridBagConstraints2(0, 4, 1, 1, 0.0, 0.0
  147.             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 24, 0, 0), 24, 0));
  148.     bevelPanel4.add(textCreditCardNumber, new GridBagConstraints2(1, 3, 2, 1, 1.0, 0.0
  149.             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 161, 0));
  150.     bevelPanel4.add(label2, new GridBagConstraints2(0, 3, 1, 1, 0.0, 0.0
  151.             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 24, 0, 0), -2, 0));
  152.     bevelPanel4.add(label5, new GridBagConstraints2(0, 2, 4, 1, 0.0, 0.0
  153.             ,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 0), 48, 0));
  154.     bevelPanel4.add(label4, new GridBagConstraints2(0, 1, 4, 1, 0.0, 0.0
  155.             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 46, 0));
  156.     bevelPanel4.add(label3, new GridBagConstraints2(0, 0, 4, 1, 0.0, 0.0
  157.             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 52, 0));
  158.   }
  159.  
  160.   /**
  161.   * Sets the text of the visual controls to reflect the credit card information
  162.   * Invoked by the Applet after an applicant has been approved.
  163.   *
  164.   * Format the output using the current Locale
  165.   */
  166.   public void setCreditCardInformation(creditApprovalStruct creditCardInfo) {
  167.  
  168.     textCreditCardNumber.setText(creditCardInfo.creditCardNumber);
  169.     textCreditLimit.setText(NumberFormat.getCurrencyInstance().format(creditCardInfo.limit));
  170.     textExpirationDate.setText(DateFormat.getDateInstance( DateFormat.SHORT ).format(
  171.           java.sql.Date.valueOf( creditCardInfo.expirationDate)));
  172.   }
  173.  
  174.   /**
  175.   * Destroy the applet when the user presses the OK button
  176.   */
  177.   void buttonControl1_actionPerformed(ActionEvent e) {
  178.     if (theApplet != null)
  179.       theApplet.destroyApplet();
  180.   }
  181.  
  182. }
  183.  
  184. /**
  185. * ActionListner Class used for the OK button
  186. */
  187. class ApplicationApprovedPanel_buttonControl1_actionAdapter implements java.awt.event.ActionListener{
  188.   ApplicationApprovedPanel adaptee;
  189.  
  190.   ApplicationApprovedPanel_buttonControl1_actionAdapter(ApplicationApprovedPanel adaptee) {
  191.     this.adaptee = adaptee;
  192.   }
  193.  
  194.   public void actionPerformed(ActionEvent e) {
  195.     adaptee.buttonControl1_actionPerformed(e);
  196.   }
  197. }
  198.  
  199.  
  200.