home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / sampjdbc.zip / LOGONDIALOG.JAV < prev    next >
Encoding:
Text File  |  2002-10-02  |  4.9 KB  |  155 lines

  1.  
  2. /*************************************************************************
  3.  *
  4.  * LogonDialog.java
  5.  *
  6.  * ⌐ Copyright 1998 Ardent Software, Inc. - All Rights Reserved
  7.  * This is unpublished proprietary source code of Ardent Software, Inc.
  8.  * The copyright notice above does not evidence any actual or intended
  9.  * publication of such source code.
  10.  *
  11.  *************************************************************************
  12.  *
  13.  * Maintenance Log - Insert most recent change descriptions at top
  14.  *
  15.  * Date.... Descrition......................................
  16.  * 11/24/98 Remove extra comments
  17.  * 11/12/98 Initial Creation for SCT1
  18.  *************************************************************************/
  19.  
  20. import java.awt.*;
  21. import java.awt.event.*;
  22.  
  23. /**
  24.  * <code>LogonDialog</code> is a class constructed to gather the necessary
  25.  * information from the user to open a connection to UniVerse.
  26.  *
  27.  * @version    Version 1.0
  28.  * @author    Ardent
  29.  * @since      1.0
  30.  */
  31.  
  32. public class LogonDialog extends Dialog
  33. {
  34.     // graphical elements for this dialog
  35.     private Label lUserName, lPassword, lServer, lAccountPath, lProxyServer, lAccessToken;
  36.     private TextField tUserName, tPassword, tServer, tAccount, tProxyServer, tAccessToken;
  37.     private Button bOK, bCancel;
  38.     private Color labelColor = new Color(139,0,0); // Dark Red
  39.     private CatalogDemo parentApplet; // reference to our parent
  40.  
  41.     LogonDialog(Frame f, CatalogDemo catalogDemo) {
  42.         this(f, catalogDemo, "UniVerse Logon");
  43.     }
  44.     LogonDialog(Frame f,CatalogDemo catalogDemo,String title) {
  45.         super(f,title,true);
  46.         parentApplet = catalogDemo;
  47.  
  48.         GridBagLayout gbl = new GridBagLayout();
  49.         setLayout(gbl);
  50.         GridBagConstraints gbc1 = new GridBagConstraints();
  51.         GridBagConstraints gbc2 = new GridBagConstraints();
  52.         gbc1.weighty = 1.0;
  53.         gbc2.weighty = 1.0;
  54.         gbc1.anchor = GridBagConstraints.EAST;
  55.         gbc2.anchor = GridBagConstraints.WEST;
  56.         gbc2.gridwidth = GridBagConstraints.REMAINDER;
  57.  
  58.       tUserName = new TextField(parentApplet.userName,20);
  59.         tUserName.setForeground(parentApplet.textColor);
  60.       tPassword = new TextField(parentApplet.password,20);
  61.         tPassword.setForeground(parentApplet.textColor);
  62.     tPassword.setEchoChar('*');
  63.       tServer = new TextField(parentApplet.server,20);
  64.         tServer.setForeground(parentApplet.textColor);
  65.       tAccount = new TextField(parentApplet.accountPath,20);
  66.         tAccount.setForeground(parentApplet.textColor);
  67.       tProxyServer = new TextField(parentApplet.proxyServer,20);
  68.         tProxyServer.setForeground(parentApplet.textColor);
  69.       tAccessToken = new TextField(parentApplet.accessToken,20);
  70.         tAccessToken.setForeground(parentApplet.textColor);
  71.  
  72.         bOK = new Button("OK");
  73.         bOK.setForeground(parentApplet.textColor);
  74.         bOK.setBackground(parentApplet.buttonColor);
  75.         bCancel = new Button("Cancel");
  76.         bCancel.setForeground(parentApplet.textColor);
  77.         bCancel.setBackground(parentApplet.buttonColor);
  78.  
  79.         add(gbl,gbc1,lUserName=new Label("UserName:"));
  80.         lUserName.setForeground(labelColor);
  81.         add(gbl,gbc2,tUserName);
  82.         add(gbl,gbc1,lPassword=new Label("Password:"));
  83.         lPassword.setForeground(labelColor);
  84.         add(gbl,gbc2,tPassword);
  85.         add(gbl,gbc1,lServer=new Label("Server:"));
  86.         lServer.setForeground(labelColor);
  87.         add(gbl,gbc2,tServer);
  88.         add(gbl,gbc1,lAccountPath=new Label("Account Path:"));
  89.         lAccountPath.setForeground(labelColor);
  90.         add(gbl,gbc2,tAccount);
  91.         add(gbl,gbc1,lProxyServer=new Label("Proxy Server:"));
  92.         lProxyServer.setForeground(labelColor);
  93.         add(gbl,gbc2,tProxyServer);
  94.         add(gbl,gbc1,lAccessToken=new Label("Access Token:"));
  95.         lAccessToken.setForeground(labelColor);
  96.         add(gbl,gbc2,tAccessToken);
  97.         add(gbl,gbc1,bOK);
  98.         add(gbl,gbc2,bCancel);
  99.  
  100.         bOK.addActionListener(new ActionListener()
  101.             {
  102.                                 String r = "new String";
  103.                 public void actionPerformed(ActionEvent event)
  104.                 {
  105.                     // pass the entered parameters to the parent applet
  106.                     parentApplet.userName = tUserName.getText();
  107.                     parentApplet.password = tPassword.getText();
  108.                     parentApplet.server = tServer.getText();
  109.                     parentApplet.accountPath = tAccount.getText();
  110.                     parentApplet.proxyServer = tProxyServer.getText();
  111.                     parentApplet.accessToken = tAccessToken.getText();
  112.                     parentApplet.cancelConnect = false;
  113.                     setVisible(false);
  114.                     dispose();
  115.                 }
  116.             }
  117.         );
  118.         bCancel.addActionListener(new ActionListener()
  119.             {
  120.                 public void actionPerformed(ActionEvent event)
  121.                 {
  122.                     // cancel connect operation
  123.                     parentApplet.cancelConnect = true;
  124.                     setVisible(false);
  125.                     dispose();
  126.                 }
  127.             }
  128.         );
  129.         addWindowListener(new WindowAdapter()
  130.             {
  131.                 public void windowClosing(WindowEvent event)
  132.                 {
  133.                     setVisible(false);
  134.                     dispose();
  135.                 }
  136.             }
  137.         );
  138.  
  139.          Point scrnLoc = parentApplet.myFrame.getLocationOnScreen();
  140.         setLocation(scrnLoc.x + 150, scrnLoc.y + 100);
  141.  
  142.         setSize(300,280);
  143.         setVisible(true);
  144.         /* for some reason requestFocus and transferFocus are not working */
  145.         bOK.requestFocus();
  146.         bOK.transferFocus();
  147.     }
  148.  
  149.     // Macro for adding components
  150.     void add(GridBagLayout gb,GridBagConstraints c,Component o)
  151.     {
  152.         gb.setConstraints(o,c);
  153.         add(o);
  154.     }
  155. }