src/java.desktop/share/classes/java/awt/TextField.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 202         this.columns = (columns >= 0) ? columns : 0;
 203     }
 204 
 205     /**
 206      * Construct a name for this component.  Called by getName() when the
 207      * name is null.
 208      */
 209     String constructComponentName() {
 210         synchronized (TextField.class) {
 211             return base + nameCounter++;
 212         }
 213     }
 214 
 215     /**
 216      * Creates the TextField's peer.  The peer allows us to modify the
 217      * appearance of the TextField without changing its functionality.
 218      */
 219     public void addNotify() {
 220         synchronized (getTreeLock()) {
 221             if (peer == null)
 222                 peer = getToolkit().createTextField(this);
 223             super.addNotify();
 224         }
 225     }
 226 
 227     /**
 228      * Gets the character that is to be used for echoing.
 229      * <p>
 230      * An echo character is useful for text fields where
 231      * user input should not be echoed to the screen, as in
 232      * the case of a text field for entering a password.
 233      * If <code>echoChar</code> = <code>0</code>, user
 234      * input is echoed to the screen unchanged.
 235      * <p>
 236      * A Java platform implementation may support only a limited,
 237      * non-empty set of echo characters. This function returns the
 238      * echo character originally requested via setEchoChar(). The echo
 239      * character actually used by the TextField implementation might be
 240      * different.
 241      * @return      the echo character for this text field.
 242      * @see         java.awt.TextField#echoCharIsSet


   1 /*
   2  * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 202         this.columns = (columns >= 0) ? columns : 0;
 203     }
 204 
 205     /**
 206      * Construct a name for this component.  Called by getName() when the
 207      * name is null.
 208      */
 209     String constructComponentName() {
 210         synchronized (TextField.class) {
 211             return base + nameCounter++;
 212         }
 213     }
 214 
 215     /**
 216      * Creates the TextField's peer.  The peer allows us to modify the
 217      * appearance of the TextField without changing its functionality.
 218      */
 219     public void addNotify() {
 220         synchronized (getTreeLock()) {
 221             if (peer == null)
 222                 peer = getComponentFactory().createTextField(this);
 223             super.addNotify();
 224         }
 225     }
 226 
 227     /**
 228      * Gets the character that is to be used for echoing.
 229      * <p>
 230      * An echo character is useful for text fields where
 231      * user input should not be echoed to the screen, as in
 232      * the case of a text field for entering a password.
 233      * If <code>echoChar</code> = <code>0</code>, user
 234      * input is echoed to the screen unchanged.
 235      * <p>
 236      * A Java platform implementation may support only a limited,
 237      * non-empty set of echo characters. This function returns the
 238      * echo character originally requested via setEchoChar(). The echo
 239      * character actually used by the TextField implementation might be
 240      * different.
 241      * @return      the echo character for this text field.
 242      * @see         java.awt.TextField#echoCharIsSet