home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / JPasswordField.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.6 KB  |  104 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.io.IOException;
  5. import java.io.ObjectOutputStream;
  6. import javax.accessibility.AccessibleContext;
  7. import javax.swing.text.BadLocationException;
  8. import javax.swing.text.Document;
  9. import javax.swing.text.JTextComponent;
  10. import javax.swing.text.Segment;
  11.  
  12. public class JPasswordField extends JTextField {
  13.    private static final String uiClassID = "PasswordFieldUI";
  14.    private char echoChar;
  15.  
  16.    public JPasswordField() {
  17.       this((Document)null, (String)null, 0);
  18.    }
  19.  
  20.    public JPasswordField(String var1) {
  21.       this((Document)null, var1, 0);
  22.    }
  23.  
  24.    public JPasswordField(int var1) {
  25.       this((Document)null, (String)null, var1);
  26.    }
  27.  
  28.    public JPasswordField(String var1, int var2) {
  29.       this((Document)null, var1, var2);
  30.    }
  31.  
  32.    public JPasswordField(Document var1, String var2, int var3) {
  33.       super(var1, var2, var3);
  34.       this.echoChar = '*';
  35.    }
  36.  
  37.    public String getUIClassID() {
  38.       return "PasswordFieldUI";
  39.    }
  40.  
  41.    public char getEchoChar() {
  42.       return this.echoChar;
  43.    }
  44.  
  45.    public void setEchoChar(char var1) {
  46.       this.echoChar = var1;
  47.    }
  48.  
  49.    public boolean echoCharIsSet() {
  50.       return this.echoChar != 0;
  51.    }
  52.  
  53.    public void cut() {
  54.       ((Component)this).getToolkit().beep();
  55.    }
  56.  
  57.    public void copy() {
  58.       ((Component)this).getToolkit().beep();
  59.    }
  60.  
  61.    public String getText() {
  62.       return super.getText();
  63.    }
  64.  
  65.    public String getText(int var1, int var2) throws BadLocationException {
  66.       return super.getText(var1, var2);
  67.    }
  68.  
  69.    public char[] getPassword() {
  70.       Document var1 = ((JTextComponent)this).getDocument();
  71.       Segment var2 = new Segment();
  72.  
  73.       try {
  74.          var1.getText(0, var1.getLength(), var2);
  75.       } catch (BadLocationException var4) {
  76.          return null;
  77.       }
  78.  
  79.       char[] var3 = new char[var2.count];
  80.       System.arraycopy(var2.array, var2.offset, var3, 0, var2.count);
  81.       return var3;
  82.    }
  83.  
  84.    private void writeObject(ObjectOutputStream var1) throws IOException {
  85.       var1.defaultWriteObject();
  86.       if (super.ui != null && this.getUIClassID().equals("PasswordFieldUI")) {
  87.          super.ui.installUI(this);
  88.       }
  89.  
  90.    }
  91.  
  92.    protected String paramString() {
  93.       return super.paramString() + ",echoChar=" + this.echoChar;
  94.    }
  95.  
  96.    public AccessibleContext getAccessibleContext() {
  97.       if (super.accessibleContext == null) {
  98.          super.accessibleContext = new AccessibleJPasswordField(this);
  99.       }
  100.  
  101.       return super.accessibleContext;
  102.    }
  103. }
  104.