home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / vpojava.DLL / SOURCE / PASSWORD_DIALOG < prev    next >
Text File  |  1998-03-18  |  3KB  |  113 lines

  1. import java.awt.*;
  2. import symantec.itools.awt.util.dialog.ModalDialog;
  3.  
  4. public class PasswordDialog extends ModalDialog
  5. {
  6.     public PasswordDialog(Frame parent, String title)
  7.     {
  8.         super(parent, title);
  9.  
  10.         // This code is automatically generated by Visual Cafe when you add
  11.         // components to the visual environment. It instantiates and initializes
  12.         // the components. To modify the code, only use code syntax that matches
  13.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  14.         // parse your Java file into its visual environment.
  15.         //{{INIT_CONTROLS
  16.         setLayout(null);
  17.         setSize(215, 130);
  18.  
  19.         nameLabel = new Label("Name:");
  20.         nameLabel.setBounds(10, 32, 75, 15);
  21.         add(nameLabel);
  22.  
  23.         passwordLabel = new Label("Password:");
  24.         passwordLabel.setBounds(10, 60, 75, 15);
  25.         add(passwordLabel);
  26.  
  27.         userTextField = new TextField(1);
  28.         userTextField.setBounds(85, 28, 100, 22);
  29.         add(userTextField);
  30.  
  31.         passTextField = new TextField(1);
  32.         passTextField.setEchoCharacter('*');
  33.         passTextField.setBounds(85, 57, 100, 22);
  34.         add(passTextField);
  35.  
  36.         okButton = new Button("OK");
  37.         okButton.setBounds(80, 95, 40, 20);
  38.         add(okButton);
  39.         //}}
  40.  
  41.     }
  42.  
  43.     public PasswordDialog(Frame parent)
  44.     {
  45.         this(parent, "Username/Password");
  46.     }
  47.  
  48.     // Add a constructor for Interactions (ignoring modal)
  49.     public PasswordDialog(Frame parent, boolean modal)
  50.     {
  51.         this(parent);
  52.     }
  53.  
  54.     // Add a constructor for Interactions (ignoring modal)
  55.     public PasswordDialog(Frame parent, String title, boolean modal)
  56.     {
  57.         this(parent, title);
  58.     }
  59.  
  60.     public String getUserName()
  61.     {
  62.         return userTextField.getText();
  63.     }
  64.  
  65.     public String getPassword()
  66.     {
  67.         return passTextField.getText();
  68.     }
  69.  
  70.     public void setUserName(String name)
  71.     {
  72.         userTextField.setText(name);
  73.     }
  74.  
  75.     public void setPassword(String pass)
  76.     {
  77.         passTextField.setText(pass);
  78.     }
  79.  
  80.     public void addNotify()
  81.     {
  82.         // Record the size of the window prior to calling parents addNotify.
  83.         Dimension d = getSize();
  84.         
  85.         super.addNotify();
  86.  
  87.         if (fComponentsAdjusted)
  88.             return;
  89.  
  90.         // Adjust components according to the insets
  91.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  92.         Component components[] = getComponents();
  93.         for (int i = 0; i < components.length; i++)
  94.         {
  95.             Point p = components[i].getLocation();
  96.             p.translate(insets().left, insets().top);
  97.             components[i].setLocation(p);
  98.         }
  99.         fComponentsAdjusted = true;
  100.     }
  101.     
  102.     // Used for addNotify check.
  103.     boolean fComponentsAdjusted = false;
  104.  
  105.     //{{DECLARE_CONTROLS
  106.     java.awt.Label nameLabel;
  107.     java.awt.Label passwordLabel;
  108.     java.awt.TextField userTextField;
  109.     java.awt.TextField passTextField;
  110.     java.awt.Button okButton;
  111.     //}}
  112. }
  113.