1   /*  UserPasswordDialog.java
2    *
3    *  Copyright (c) 1998-2001, The University of Sheffield.
4    *
5    *  This file is part of GATE (see http://gate.ac.uk/), and is free
6    *  software, licenced under the GNU Library General Public License,
7    *  Version 2, June 1991 (in the distribution as file licence.html,
8    *  and also available at http://gate.ac.uk/gate/licence.html).
9    *
10   *  Kalina Bontcheva,  03/October/2001
11   *
12   *  $Id: UserPasswordDialog.java,v 1.1 2001/10/17 17:16:57 kalina Exp $
13   *
14   */
15  
16  package gate.gui;
17  
18  import javax.swing.*;
19  import java.awt.*;
20  
21  
22  public class UserPasswordDialog {
23  
24    String userName = "";
25    String userPass = "";
26  
27    public UserPasswordDialog() {
28    }
29  
30    public boolean showPasswordDialog(String message, Component parent) {
31  
32      JPanel listPanel = new JPanel();
33      listPanel.setLayout(new BoxLayout(listPanel,BoxLayout.X_AXIS));
34  
35      JPanel panel1 = new JPanel();
36      panel1.setLayout(new BoxLayout(panel1,BoxLayout.Y_AXIS));
37      panel1.add(new JLabel("User name: "));
38      panel1.add(new JLabel("Password: "));
39  
40      JPanel panel2 = new JPanel();
41      panel2.setLayout(new BoxLayout(panel2,BoxLayout.Y_AXIS));
42      JTextField usrField = new JTextField(30);
43      panel2.add(usrField);
44      JPasswordField pwdField = new JPasswordField(30);
45      panel2.add(pwdField);
46  
47      listPanel.add(panel1);
48      listPanel.add(Box.createHorizontalStrut(30));
49      listPanel.add(panel2);
50  
51      if(OkCancelDialog.showDialog( parent,
52                                    listPanel,
53                                    message)){
54        userName = usrField.getText();
55        userPass = new String(pwdField.getPassword());
56        return true;
57      }
58  
59      return false;
60    }
61  
62    public String getUserName() {
63      return userName;
64    }
65  
66    public String getPassword() {
67      return userPass;
68    }
69  
70  }