AccessibleEditableText.java revision 17405:415b0831244f
1/*
2 * Copyright (c) 2000, 2017, 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
23 * questions.
24 */
25
26package javax.accessibility;
27
28import javax.swing.text.AttributeSet;
29
30/**
31 * The {@code AccessibleEditableText} interface should be implemented by all
32 * classes that present editable textual information on the display. Along with
33 * the {@code AccessibleText} interface, this interface provides the standard
34 * mechanism for an assistive technology to access that text via its content,
35 * attributes, and spatial location. Applications can determine if an object
36 * supports the {@code AccessibleEditableText} interface by first obtaining its
37 * {@code AccessibleContext} (see {@link Accessible}) and then calling the
38 * {@link AccessibleContext#getAccessibleEditableText} method of
39 * {@code AccessibleContext}. If the return value is not {@code null}, the
40 * object supports this interface.
41 *
42 * @author Lynn Monsanto
43 * @see Accessible
44 * @see Accessible#getAccessibleContext
45 * @see AccessibleContext
46 * @see AccessibleContext#getAccessibleText
47 * @see AccessibleContext#getAccessibleEditableText
48 * @since 1.4
49 */
50public interface AccessibleEditableText extends AccessibleText {
51
52    /**
53     * Sets the text contents to the specified string.
54     *
55     * @param  s the string to set the text contents
56     */
57    public void setTextContents(String s);
58
59    /**
60     * Inserts the specified string at the given index.
61     *
62     * @param  index the index in the text where the string will be inserted
63     * @param  s the string to insert in the text
64     */
65    public void insertTextAtIndex(int index, String s);
66
67    /**
68     * Returns the text string between two indices.
69     *
70     * @param  startIndex the starting index in the text
71     * @param  endIndex the ending index in the text
72     * @return the text string between the indices
73     */
74    public String getTextRange(int startIndex, int endIndex);
75
76    /**
77     * Deletes the text between two indices.
78     *
79     * @param  startIndex the starting index in the text
80     * @param  endIndex the ending index in the text
81     */
82    public void delete(int startIndex, int endIndex);
83
84    /**
85     * Cuts the text between two indices into the system clipboard.
86     *
87     * @param  startIndex the starting index in the text
88     * @param  endIndex the ending index in the text
89     */
90    public void cut(int startIndex, int endIndex);
91
92    /**
93     * Pastes the text from the system clipboard into the text starting at the
94     * specified index.
95     *
96     * @param  startIndex the starting index in the text
97     */
98    public void paste(int startIndex);
99
100    /**
101     * Replaces the text between two indices with the specified string.
102     *
103     * @param  startIndex the starting index in the text
104     * @param  endIndex the ending index in the text
105     * @param  s the string to replace the text between two indices
106     */
107    public void replaceText(int startIndex, int endIndex, String s);
108
109    /**
110     * Selects the text between two indices.
111     *
112     * @param  startIndex the starting index in the text
113     * @param  endIndex the ending index in the text
114     */
115    public void selectText(int startIndex, int endIndex);
116
117    /**
118     * Sets attributes for the text between two indices.
119     *
120     * @param  startIndex the starting index in the text
121     * @param  endIndex the ending index in the text
122     * @param  as the attribute set
123     * @see AttributeSet
124     */
125    public void setAttributes(int startIndex, int endIndex, AttributeSet as);
126}
127