home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / TRIAL / JBUILDER / JVISBRKR.Z / ClientApplet.java < prev    next >
Encoding:
Java Source  |  1998-05-08  |  2.3 KB  |  59 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. package visibroker.samples.bank;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import org.omg.CORBA.*;
  25.  
  26. public class ClientApplet extends java.applet.Applet implements ActionListener {
  27.  
  28.   private TextField _nameField, _balanceField;
  29.   private Button _checkBalance;
  30.   private Bank.AccountManager _manager;
  31.  
  32.   public void init() {
  33.     // This GUI uses a 2 by 2 grid of widgets.
  34.     setLayout(new GridLayout(2, 2, 5, 5));
  35.     // Add the four widgets.
  36.     add(new Label("Account Name"));
  37.     add(_nameField = new TextField());
  38.     add(_checkBalance = new Button("Check Balance"));
  39.     add(_balanceField = new TextField());
  40.     // make the balance text field non-editable.
  41.     _balanceField.setEditable(false);
  42.     // Enable action events for the _checkBalance button.
  43.     _checkBalance.addActionListener(this);
  44.     // Initialize the ORB (using the Applet).
  45.     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(this, null);
  46.     // Locate an account manager.
  47.     _manager = Bank.AccountManagerHelper.bind(orb, "BankManager");
  48.   }
  49.  
  50.   public void actionPerformed(ActionEvent ev) {
  51.     // Request the account manager to open a named account.
  52.     // Get the account name from the name text widget.
  53.     Bank.Account account = _manager.open(_nameField.getText());
  54.     // Set the balance text widget to the account's balance.
  55.     _balanceField.setText(Float.toString(account.balance()));
  56.   }
  57.  
  58. }
  59.