home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.TextFieldPeer;
-
- public class TextField extends TextComponent {
- int cols;
- char echoChar;
-
- public TextField() {
- super("");
- }
-
- public TextField(int cols) {
- super("");
- this.cols = cols;
- }
-
- public TextField(String text) {
- super(text);
- }
-
- public TextField(String text, int cols) {
- super(text);
- this.cols = cols;
- }
-
- public synchronized void addNotify() {
- super.peer = ((Component)this).getToolkit().createTextField(this);
- super.addNotify();
- }
-
- public char getEchoChar() {
- return this.echoChar;
- }
-
- public boolean echoCharIsSet() {
- return this.echoChar != 0;
- }
-
- public int getColumns() {
- return this.cols;
- }
-
- public void setEchoCharacter(char c) {
- this.echoChar = c;
- TextFieldPeer peer = (TextFieldPeer)super.peer;
- if (peer != null) {
- peer.setEchoCharacter(c);
- }
-
- }
-
- public Dimension preferredSize(int cols) {
- TextFieldPeer peer = (TextFieldPeer)super.peer;
- return peer != null ? peer.preferredSize(cols) : super.preferredSize();
- }
-
- public Dimension preferredSize() {
- return this.cols > 0 ? this.preferredSize(this.cols) : super.preferredSize();
- }
-
- public Dimension minimumSize(int cols) {
- TextFieldPeer peer = (TextFieldPeer)super.peer;
- return peer != null ? peer.minimumSize(cols) : super.minimumSize();
- }
-
- public Dimension minimumSize() {
- return this.cols > 0 ? this.minimumSize(this.cols) : super.minimumSize();
- }
-
- protected String paramString() {
- String str = super.paramString();
- if (this.echoChar != 0) {
- str = str + ",echo=" + this.echoChar;
- }
-
- return str;
- }
- }
-