home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / awt / TextField.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  2.3 KB  |  80 lines

  1. package java.awt;
  2.  
  3. import java.awt.peer.TextFieldPeer;
  4.  
  5. public class TextField extends TextComponent {
  6.    int cols;
  7.    char echoChar;
  8.  
  9.    public TextField() {
  10.       super("");
  11.    }
  12.  
  13.    public TextField(int cols) {
  14.       super("");
  15.       this.cols = cols;
  16.    }
  17.  
  18.    public TextField(String text) {
  19.       super(text);
  20.    }
  21.  
  22.    public TextField(String text, int cols) {
  23.       super(text);
  24.       this.cols = cols;
  25.    }
  26.  
  27.    public synchronized void addNotify() {
  28.       super.peer = ((Component)this).getToolkit().createTextField(this);
  29.       super.addNotify();
  30.    }
  31.  
  32.    public char getEchoChar() {
  33.       return this.echoChar;
  34.    }
  35.  
  36.    public boolean echoCharIsSet() {
  37.       return this.echoChar != 0;
  38.    }
  39.  
  40.    public int getColumns() {
  41.       return this.cols;
  42.    }
  43.  
  44.    public void setEchoCharacter(char c) {
  45.       this.echoChar = c;
  46.       TextFieldPeer peer = (TextFieldPeer)super.peer;
  47.       if (peer != null) {
  48.          peer.setEchoCharacter(c);
  49.       }
  50.  
  51.    }
  52.  
  53.    public Dimension preferredSize(int cols) {
  54.       TextFieldPeer peer = (TextFieldPeer)super.peer;
  55.       return peer != null ? peer.preferredSize(cols) : super.preferredSize();
  56.    }
  57.  
  58.    public Dimension preferredSize() {
  59.       return this.cols > 0 ? this.preferredSize(this.cols) : super.preferredSize();
  60.    }
  61.  
  62.    public Dimension minimumSize(int cols) {
  63.       TextFieldPeer peer = (TextFieldPeer)super.peer;
  64.       return peer != null ? peer.minimumSize(cols) : super.minimumSize();
  65.    }
  66.  
  67.    public Dimension minimumSize() {
  68.       return this.cols > 0 ? this.minimumSize(this.cols) : super.minimumSize();
  69.    }
  70.  
  71.    protected String paramString() {
  72.       String str = super.paramString();
  73.       if (this.echoChar != 0) {
  74.          str = str + ",echo=" + this.echoChar;
  75.       }
  76.  
  77.       return str;
  78.    }
  79. }
  80.