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
24 */
25 package java.awt;
26
27 import java.awt.peer.TextFieldPeer;
28 import java.awt.event.*;
29 import java.util.EventListener;
30 import java.io.ObjectOutputStream;
31 import java.io.ObjectInputStream;
32 import java.io.IOException;
33 import javax.accessibility.*;
34
35
36 /**
37 * A {@code TextField} object is a text component
38 * that allows for the editing of a single line of text.
39 * <p>
40 * For example, the following image depicts a frame with four
41 * text fields of varying widths. Two of these text fields
42 * display the predefined text {@code "Hello"}.
43 * <p>
44 * <img src="doc-files/TextField-1.gif" alt="The preceding text describes this image."
45 * style="float:center; margin: 7px 10px;">
46 * <p>
47 * Here is the code that produces these four text fields:
48 *
49 * <hr><blockquote><pre>
50 * TextField tf1, tf2, tf3, tf4;
51 * // a blank text field
52 * tf1 = new TextField();
53 * // blank field of 20 columns
54 * tf2 = new TextField("", 20);
55 * // predefined text displayed
56 * tf3 = new TextField("Hello!");
57 * // predefined text in 30 columns
58 * tf4 = new TextField("Hello", 30);
59 * </pre></blockquote><hr>
60 * <p>
61 * Every time the user types a key in the text field, one or
62 * more key events are sent to the text field. A {@code KeyEvent}
63 * may be one of three types: keyPressed, keyReleased, or keyTyped.
64 * The properties of a key event indicate which of these types
65 * it is, as well as additional information about the event,
|
1 /*
2 * Copyright (c) 1995, 2019, 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
24 */
25 package java.awt;
26
27 import java.awt.peer.TextFieldPeer;
28 import java.awt.event.*;
29 import java.util.EventListener;
30 import java.io.ObjectOutputStream;
31 import java.io.ObjectInputStream;
32 import java.io.IOException;
33 import javax.accessibility.*;
34
35
36 /**
37 * A {@code TextField} object is a text component
38 * that allows for the editing of a single line of text.
39 * <p>
40 * For example, the following image depicts a frame with four
41 * text fields of varying widths. Two of these text fields
42 * display the predefined text {@code "Hello"}.
43 * <p>
44 * <img src="doc-files/TextField-1.gif" alt="The preceding text describes this
45 * image." style="margin: 7px 10px;">
46 * <p>
47 * Here is the code that produces these four text fields:
48 *
49 * <hr><blockquote><pre>
50 * TextField tf1, tf2, tf3, tf4;
51 * // a blank text field
52 * tf1 = new TextField();
53 * // blank field of 20 columns
54 * tf2 = new TextField("", 20);
55 * // predefined text displayed
56 * tf3 = new TextField("Hello!");
57 * // predefined text in 30 columns
58 * tf4 = new TextField("Hello", 30);
59 * </pre></blockquote><hr>
60 * <p>
61 * Every time the user types a key in the text field, one or
62 * more key events are sent to the text field. A {@code KeyEvent}
63 * may be one of three types: keyPressed, keyReleased, or keyTyped.
64 * The properties of a key event indicate which of these types
65 * it is, as well as additional information about the event,
|