⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicationapprovedpanel.java

📁 java在线商店的源代码。编写十分规范的哦
💻 JAVA
字号:
/**
 * Copyright (c) 1996-2004 Borland Software Corporation.  All Rights Reserved.
 * 
 * This SOURCE CODE FILE, which has been provided by Borland Software as part
 * of a Borland Software product for use ONLY by licensed users of the product,
 * includes CONFIDENTIAL and PROPRIETARY information of Borland Software.  
 *
 * 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 SOFTWARE, 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.
 */
//------------------------------------------------------------------------------
// Copyright (c) 1996-2004 Borland Software Corporation.  All Rights Reserved.
//------------------------------------------------------------------------------

package com.borland.samples.creditapproval.client;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;

import com.borland.samples.creditapproval.CORBAInterface.*;
import com.borland.dbswing.ColumnLayout;

/**
 * ApplicationApprovedPanel displays credit card information for
 * approved applicants.
 */
public class ApplicationApprovedPanel extends JPanel {
  JLabel congratulatoryLabel = new JLabel();
  JPanel mainPanel = new JPanel();
  JPanel fieldOuterPanel = new JPanel();
  JLabel creditCardNoLabel = new JLabel();
  JLabel cardExpiryLabel = new JLabel();
  JLabel creditLimitLabel = new JLabel();
  JTextField creditCardNoField = new JTextField();
  JTextField expiryDateField = new JTextField();
  JTextField creditLimitField = new JTextField();
  JPanel labelPanel = new JPanel();
  JPanel fieldPanel = new JPanel();
  ColumnLayout columnLayout2 = new ColumnLayout();
  ColumnLayout columnLayout1 = new ColumnLayout();
  JPanel buttonPanel = new JPanel();
  JButton okButton = new JButton();
  JLabel imageLabel = new JLabel();
  JScrollPane jScrollPane1 = new JScrollPane();
  JTextArea messageArea = new JTextArea();
  JPanel imagePanel = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  GridBagLayout gridBagLayout2 = new GridBagLayout();
  BorderLayout borderLayout2 = new BorderLayout();
  ResourceBundle res = Res.getBundle("com.borland.samples.creditapproval.client.Res");

  private CreditApprovalApplet creditApprovalApplet;
  /**
   * Default constructor
   */
  public ApplicationApprovedPanel() {
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * Sets a reference to the CreditApprovalApplet using this panel.
   * @param creditApprovalApplet creditApprovalApplet
   *
   */
  public void setCreditApprovalApplet(CreditApprovalApplet creditApprovalApplet) {
    this.creditApprovalApplet = creditApprovalApplet;
  }

  /**
   *  Initialize the Panel
   *  @throws Exception exception
   *
   */
  private void jbInit() throws Exception{
    this.setLayout(borderLayout2);
    congratulatoryLabel.setHorizontalAlignment(SwingConstants.CENTER);
    congratulatoryLabel.setFont(new java.awt.Font("Dialog", 3, 18));
    congratulatoryLabel.setForeground(Color.red);
    congratulatoryLabel.setText(res.getString("Congratulations"));
    mainPanel.setLayout(gridBagLayout2);
    fieldOuterPanel.setLayout(gridBagLayout1);
    creditCardNoLabel.setPreferredSize(new Dimension(115, 21));
    creditCardNoLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    creditCardNoLabel.setText(res.getString("Credit_Card_Number"));
    cardExpiryLabel.setPreferredSize(new Dimension(89, 21));
    cardExpiryLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    cardExpiryLabel.setText(res.getString("Expiration_Date"));
    creditLimitLabel.setPreferredSize(new Dimension(68, 21));
    creditLimitLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    creditLimitLabel.setText(res.getString("Credit_Limit"));
    creditCardNoField.setColumns(20);
    expiryDateField.setColumns(10);
    creditLimitField.setColumns(10);
    labelPanel.setLayout(columnLayout2);
    fieldPanel.setLayout(columnLayout1);
    columnLayout1.setHorizontalFill(false);
    columnLayout1.setHorizontalAlignment(ColumnLayout.LEFT);
    okButton.setText(res.getString("OK"));
    okButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        okButton_actionPerformed(e);
      }
    });
    imageLabel.setIcon(new ImageIcon(this.getClass().getResource("images/logo.gif")));
    messageArea.setLineWrap(true);
    messageArea.setWrapStyleWord(true);
    messageArea.setText(res.getString("You_have_been_approved"));
    messageArea.setEditable(false);
    imagePanel.setLayout(borderLayout1);
    this.add(congratulatoryLabel, BorderLayout.NORTH);
    this.add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(fieldOuterPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    fieldOuterPanel.add(labelPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    labelPanel.add(creditCardNoLabel, null);
    labelPanel.add(creditLimitLabel, null);
    labelPanel.add(cardExpiryLabel, null);
    fieldOuterPanel.add(fieldPanel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    fieldPanel.add(creditCardNoField, null);
    fieldPanel.add(creditLimitField, null);
    fieldPanel.add(expiryDateField, null);
    mainPanel.add(jScrollPane1, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
    mainPanel.add(imagePanel, new GridBagConstraints(2, 0, 1, 2, 0.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(10, 10, 10, 10), 0, 0));
    imagePanel.add(imageLabel, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(messageArea, null);
    this.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.add(okButton, null);
  }

  /**
   * Sets the text of the visual controls to reflect the credit card information
   * Invoked by the Applet after an applicant has been approved.
   *
   * Formats the output using the current Locale
   * @param creditCardInfo creditApprovalStruct
   *
   */
  public void setCreditCardInformation(creditApprovalStruct creditCardInfo) {
    creditCardNoField.setText(creditCardInfo.creditCardNumber);
    creditLimitField.setText(NumberFormat.getCurrencyInstance().format(creditCardInfo.limit));
    expiryDateField.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(java.sql.Date.valueOf(creditCardInfo.expirationDate)));
  }

  /**
   * Destroys the applet when the user presses the OK button
   * @param e Action Event
   */
  void okButton_actionPerformed(ActionEvent e) {
    if (creditApprovalApplet != null) {
      creditApprovalApplet.destroyApplet();
    }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -