home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / frei / vnc-java.arj / VNC-JAVA.ZIP / authenticationPanel.java < prev    next >
Encoding:
Java Source  |  1998-01-15  |  2.6 KB  |  109 lines

  1. //
  2. //  Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
  3. //
  4. //  This is free software; you can redistribute it and/or modify
  5. //  it under the terms of the GNU General Public License as published by
  6. //  the Free Software Foundation; either version 2 of the License, or
  7. //  (at your option) any later version.
  8. //
  9. //  This software is distributed in the hope that it will be useful,
  10. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //  GNU General Public License for more details.
  13. //
  14. //  You should have received a copy of the GNU General Public License
  15. //  along with this software; if not, write to the Free Software
  16. //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  17. //  USA.
  18. //
  19.  
  20. import java.awt.*;
  21.  
  22. //
  23. // The panel which implements the user authentication scheme
  24. //
  25.  
  26. class authenticationPanel extends Panel {
  27.  
  28.   Label title, retry, prompt;
  29.   TextField password;
  30.   Button ok;
  31.  
  32.   //
  33.   // Constructor.
  34.   //
  35.  
  36.   public authenticationPanel() {
  37.  
  38.     title = new Label("VNC Authentication",Label.CENTER);
  39.     title.setFont(new Font("Helvetica", Font.BOLD, 18));
  40.  
  41.     prompt = new Label("Password:",Label.CENTER);
  42.  
  43.     password = new TextField(10);
  44.     password.setForeground(Color.black);
  45.     password.setBackground(Color.white);
  46.     password.setEchoCharacter('*');
  47.  
  48.     ok = new Button("OK");
  49.  
  50.     retry = new Label("",Label.CENTER);
  51.     retry.setFont(new Font("Courier", Font.BOLD, 16));
  52.  
  53.  
  54.     GridBagLayout gridbag = new GridBagLayout();
  55.     GridBagConstraints gbc = new GridBagConstraints();
  56.  
  57.     setLayout(gridbag);
  58.  
  59.     gbc.gridwidth = GridBagConstraints.REMAINDER;
  60.     gridbag.setConstraints(title,gbc);
  61.     add(title);
  62.  
  63.     gbc.fill = GridBagConstraints.HORIZONTAL;
  64.     gridbag.setConstraints(retry,gbc);
  65.     add(retry);
  66.  
  67.     gbc.fill = GridBagConstraints.NONE;
  68.     gbc.gridwidth = 1;
  69.     gridbag.setConstraints(prompt,gbc);
  70.     add(prompt);
  71.  
  72.     gridbag.setConstraints(password,gbc);
  73.     add(password);
  74.  
  75.     gbc.ipady = 10;
  76.     gbc.gridwidth = GridBagConstraints.REMAINDER;
  77.     gbc.fill = GridBagConstraints.BOTH;
  78.     gbc.insets = new Insets(0,20,0,0);
  79.     gbc.ipadx = 40;
  80.     gridbag.setConstraints(ok,gbc);
  81.     add(ok);
  82.  
  83.     password.requestFocus();
  84.   }
  85.  
  86.   //
  87.   // action() is called when a button is pressed or return is pressed in the
  88.   // password text field.
  89.   //
  90.  
  91.   public synchronized boolean action(Event evt, Object arg){
  92.     if ((evt.target == password) || (evt.target == ok)) {
  93.       notify();
  94.       return true;
  95.     }
  96.     return false;
  97.   }
  98.  
  99.   //
  100.   // retry().
  101.   //
  102.  
  103.   public void retry() {
  104.     retry.setText("Sorry. Try again.");
  105.     password.setText("");
  106.   }
  107.  
  108. }
  109.