jdk/src/java.desktop/share/classes/java/awt/List.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 25162 jdk/src/share/classes/java/awt/List.java@c388078278d4
child 26749 b6598aa90114
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
     2
 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.peer.ListPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * The <code>List</code> component presents the user with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * scrolling list of text items. The list can be set up so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the user can choose either one item or multiple items.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * For example, the code&nbsp;.&nbsp;.&nbsp;.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
    44
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <hr><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * List lst = new List(4, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * lst.add("Mercury");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * lst.add("Venus");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * lst.add("Earth");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * lst.add("JavaSoft");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * lst.add("Mars");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * lst.add("Jupiter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * lst.add("Saturn");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * lst.add("Uranus");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * lst.add("Neptune");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * lst.add("Pluto");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * cnt.add(lst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * </pre></blockquote><hr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * where <code>cnt</code> is a container, produces the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * scrolling list:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <img src="doc-files/List-1.gif"
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 16734
diff changeset
    64
 * alt="Shows a list containing: Venus, Earth, JavaSoft, and Mars. Javasoft is selected." style="float:center; margin: 7px 10px;">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * If the List allows multiple selections, then clicking on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * an item that is already selected deselects it. In the preceding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * example, only one item from the scrolling list can be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * at a time, since the second argument when creating the new scrolling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * list is <code>false</code>. If the List does not allow multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * selections, selecting an item causes any other selected item
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * to be deselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Note that the list in the example shown was created with four visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * rows.  Once the list has been created, the number of visible rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * cannot be changed.  A default <code>List</code> is created with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * four rows, so that <code>lst = new List()</code> is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * <code>list = new List(4, false)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * Beginning with Java&nbsp;1.1, the Abstract Window Toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * sends the <code>List</code> object all mouse, keyboard, and focus events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * that occur over it. (The old AWT event model is being maintained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * only for backwards compatibility, and its use is discouraged.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * When an item is selected or deselected by the user, AWT sends an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * of <code>ItemEvent</code> to the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * When the user double-clicks on an item in a scrolling list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * AWT sends an instance of <code>ActionEvent</code> to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * list following the item event. AWT also generates an action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * when the user presses the return key while an item in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * list is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * If an application wants to perform some action based on an item
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * in this list being selected or activated by the user, it should implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <code>ItemListener</code> or <code>ActionListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * as appropriate and register the new listener to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * events from this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * For multiple-selection scrolling lists, it is considered a better
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * user interface to use an external gesture (such as clicking on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * button) to trigger the action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see         java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @see         java.awt.event.ItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * @see         java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @see         java.awt.event.ActionListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   107
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
public class List extends Component implements ItemSelectable, Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * A vector created to contain items which will become
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * part of the List Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see #addItem(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #getItem(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   118
    Vector<String>      items = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * This field will represent the number of visible rows in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * <code>List</code> Component.  It is specified only once, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * that is when the list component is actually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * created.  It will never change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @see #getRows()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    int         rows = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * <code>multipleMode</code> is a variable that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * be set to <code>true</code> if a list component is to be set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * multiple selection mode, that is where the user can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * select more than one item in a list at one time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * <code>multipleMode</code> will be set to false if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * list component is set to single selection, that is where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * the user can only select one item on the list at any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * one time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see #isMultipleMode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @see #setMultipleMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    boolean     multipleMode = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <code>selected</code> is an array that will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * the indices of items that have been selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @see #getSelectedIndexes()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see #getSelectedIndex()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    int         selected[] = new int[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * This variable contains the value that will be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * when trying to make a particular list item visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @see #makeVisible(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    int         visibleIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    transient ActionListener actionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    transient ItemListener itemListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    private static final String base = "list";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     private static final long serialVersionUID = -3304312411574666869L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Creates a new scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * By default, there are four visible lines and multiple selections are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * not allowed.  Note that this is a convenience method for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * <code>List(0, false)</code>.  Also note that the number of visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * lines in the list cannot be changed after it has been created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public List() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        this(0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * Creates a new scrolling list initialized with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * number of visible lines. By default, multiple selections are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * not allowed.  Note that this is a convenience method for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * <code>List(rows, false)</code>.  Also note that the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * of visible rows in the list cannot be changed after it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * been created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @param       rows the number of items to show.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see java.awt.GraphicsEnvironment#isHeadless
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   202
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public List(int rows) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        this(rows, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * The default number of visible rows is 4.  A list with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * zero rows is unusable and unsightly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    final static int    DEFAULT_VISIBLE_ROWS = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * Creates a new scrolling list initialized to display the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * number of rows. Note that if zero rows are specified, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * the list will be created with a default of four rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Also note that the number of visible rows in the list cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * be changed after it has been created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * If the value of <code>multipleMode</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <code>true</code>, then the user can select multiple items from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * the list. If it is <code>false</code>, only one item at a time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * can be selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @param       rows   the number of items to show.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @param       multipleMode   if <code>true</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *                     then multiple selections are allowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *                     otherwise, only one item can be selected at a time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public List(int rows, boolean multipleMode) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        this.rows = (rows != 0) ? rows : DEFAULT_VISIBLE_ROWS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        this.multipleMode = multipleMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Construct a name for this component.  Called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * <code>getName</code> when the name is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        synchronized (List.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Creates the peer for the list.  The peer allows us to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * list's appearance without changing its functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            if (peer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                peer = getToolkit().createList(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Removes the peer for this list.  The peer allows us to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * list's appearance without changing its functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                selected = peer.getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            super.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Gets the number of items in the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @return     the number of items in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @see        #getItem
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   278
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public int getItemCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        return countItems();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   285
     * Returns the number of items in the list.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   286
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   287
     * @return the number of items in the list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * replaced by <code>getItemCount()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public int countItems() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        return items.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Gets the item associated with the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @return       an item that is associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *                    the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param        index the position of the item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see          #getItemCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public String getItem(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return getItemImpl(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    //       We implement this functionality in a package-private method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    //       to insure that it cannot be overridden by client subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    final String getItemImpl(int index) {
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   312
        return items.elementAt(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Gets the items in the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @return       a string array containing items of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @see          #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @see          #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @see          #isIndexSelected
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   321
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public synchronized String[] getItems() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        String itemCopies[] = new String[items.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        items.copyInto(itemCopies);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        return itemCopies;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * Adds the specified item to the end of scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @param item the item to be added
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   332
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public void add(String item) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        addItem(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   339
     * Adds the specified item to the end of the list.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   340
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   341
     * @param  item the item to be added
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   342
     * @deprecated replaced by <code>add(String)</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public void addItem(String item) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        addItem(item, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Adds the specified item to the the scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * at the position indicated by the index.  The index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * zero-based.  If the value of the index is less than zero,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * or if the value of the index is greater than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * the number of items in the list, then the item is added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * to the end of the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param       item   the item to be added;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *              if this parameter is <code>null</code> then the item is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *              treated as an empty string, <code>""</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param       index  the position at which to add the item
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   360
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    public void add(String item, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        addItem(item, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   367
     * Adds the specified item to the the list
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   368
     * at the position indicated by the index.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   369
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   370
     * @param  item the item to be added
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   371
     * @param  index the position at which to add the item
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   372
     * @deprecated replaced by <code>add(String, int)</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    public synchronized void addItem(String item, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if (index < -1 || index >= items.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            index = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        if (item == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            item = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (index == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            items.addElement(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            items.insertElementAt(item, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        if (peer != null) {
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   392
            peer.add(item, index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Replaces the item at the specified index in the scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * with the new string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @param       newValue   a new string to replace an existing item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param       index      the position of the item to replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @exception ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *          is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public synchronized void replaceItem(String newValue, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        add(newValue, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Removes all items from this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @see #remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @see #delItems
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   413
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public void removeAll() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * replaced by <code>removeAll()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public synchronized void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        if (peer != null) {
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   427
            peer.removeAll();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   429
        items = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        selected = new int[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * Removes the first occurrence of an item from the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * If the specified item is selected, and is the only selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * item in the list, the list is set to have no selection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @param        item  the item to remove from the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @exception    IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *                     if the item doesn't exist in the list
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   440
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    public synchronized void remove(String item) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        int index = items.indexOf(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        if (index < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            throw new IllegalArgumentException("item " + item +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                               " not found in list");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * Removes the item at the specified position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * from this scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * If the item with the specified position is selected, and is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * only selected item in the list, the list is set to have no selection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @param      position   the index of the item to delete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @see        #add(String, int)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   459
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @exception    ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *               if the <code>position</code> is less than 0 or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *               greater than <code>getItemCount()-1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    public void remove(int position) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        delItem(position);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   469
     * Removes the item at the specified position.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   470
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   471
     * @param  position the index of the item to delete
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   472
     * @deprecated replaced by <code>remove(String)</code>
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   473
     *             and <code>remove(int)</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public void delItem(int position) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        delItems(position, position);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * Gets the index of the selected item on the list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return        the index of the selected item;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *                if no item is selected, or if multiple items are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *                selected, <code>-1</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @see           #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @see           #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @see           #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public synchronized int getSelectedIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        int sel[] = getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        return (sel.length == 1) ? sel[0] : -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * Gets the selected indexes on the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @return        an array of the selected indexes on this scrolling list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *                if no item is selected, a zero-length array is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @see           #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @see           #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see           #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    public synchronized int[] getSelectedIndexes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        if (peer != null) {
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   507
            selected = peer.getSelectedIndexes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        }
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   509
        return selected.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Gets the selected item on this scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @return        the selected item on the list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *                if no item is selected, or if multiple items are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *                selected, <code>null</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see           #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @see           #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @see           #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public synchronized String getSelectedItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        int index = getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        return (index < 0) ? null : getItem(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Gets the selected items on this scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @return        an array of the selected items on this scrolling list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *                if no item is selected, a zero-length array is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @see           #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see           #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see           #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public synchronized String[] getSelectedItems() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        int sel[] = getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        String str[] = new String[sel.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        for (int i = 0 ; i < sel.length ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            str[i] = getItem(sel[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * Gets the selected items on this scrolling list in an array of Objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @return        an array of <code>Object</code>s representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *                selected items on this scrolling list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *                if no item is selected, a zero-length array is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @see #getSelectedItems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @see ItemSelectable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    public Object[] getSelectedObjects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return getSelectedItems();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * Selects the item at the specified index in the scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Note that passing out of range parameters is invalid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * and will result in unspecified behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <p>Note that this method should be primarily used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * initially select an item in this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * Programmatically calling this method will <i>not</i> trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * an <code>ItemEvent</code>.  The only way to trigger an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * <code>ItemEvent</code> is by user interaction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @param        index the position of the item to select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @see          #getSelectedItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @see          #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @see          #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    public void select(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        // Bug #4059614: select can't be synchronized while calling the peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        // because it is called from the Window Thread.  It is sufficient to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        // synchronize the code that manipulates 'selected' except for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        // case where the peer changes.  To handle this case, we simply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        // repeat the selection process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        ListPeer peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                peer.select(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            synchronized(this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                boolean alreadySelected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                for (int i = 0 ; i < selected.length ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                    if (selected[i] == index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                        alreadySelected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                if (!alreadySelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                    if (!multipleMode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                        selected = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                        selected[0] = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                        int newsel[] = new int[selected.length + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                        System.arraycopy(selected, 0, newsel, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                                         selected.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                        newsel[selected.length] = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                        selected = newsel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        } while (peer != this.peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * Deselects the item at the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * Note that passing out of range parameters is invalid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * and will result in unspecified behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * If the item at the specified index is not selected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * then the operation is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @param        index the position of the item to deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @see          #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @see          #getSelectedItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @see          #isIndexSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public synchronized void deselect(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            if (isMultipleMode() || (getSelectedIndex() == index)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                peer.deselect(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        for (int i = 0 ; i < selected.length ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            if (selected[i] == index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                int newsel[] = new int[selected.length - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                System.arraycopy(selected, 0, newsel, 0, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                selected = newsel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * Determines if the specified item in this scrolling list is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * @param      index   the item to be checked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * @return     <code>true</code> if the specified item has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     *                       selected; <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @see        #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @see        #deselect
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   656
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    public boolean isIndexSelected(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        return isSelected(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   663
     * Determines if the specified item in the list is selected.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   664
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   665
     * @param  index specifies the item to be checked
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   666
     * @return {@code true} if the item is selected; otherwise {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * replaced by <code>isIndexSelected(int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public boolean isSelected(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        int sel[] = getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        for (int i = 0 ; i < sel.length ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            if (sel[i] == index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Gets the number of visible lines in this list.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * once the <code>List</code> has been created, this number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * will never change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @return     the number of visible lines in this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public int getRows() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        return rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * Determines whether this list allows multiple selections.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   693
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @return     <code>true</code> if this list allows multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     *                 selections; otherwise, <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * @see        #setMultipleMode
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   697
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    public boolean isMultipleMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        return allowsMultipleSelections();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   704
     * Determines whether this list allows multiple selections.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   705
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   706
     * @return {@code true} if this list allows multiple
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   707
     *         selections; otherwise {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * replaced by <code>isMultipleMode()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    public boolean allowsMultipleSelections() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        return multipleMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * Sets the flag that determines whether this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * allows multiple selections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * When the selection mode is changed from multiple-selection to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * single-selection, the selected items change as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * If a selected item has the location cursor, only that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * item will remain selected.  If no selected item has the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * location cursor, all items will be deselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * @param       b   if <code>true</code> then multiple selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     *                      are allowed; otherwise, only one item from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     *                      the list can be selected at once
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * @see         #isMultipleMode
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   728
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    public void setMultipleMode(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        setMultipleSelections(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   735
     * Enables or disables multiple selection mode for this list.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   736
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   737
     * @param  b {@code true} to enable multiple mode, {@code false} otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * replaced by <code>setMultipleMode(boolean)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    public synchronized void setMultipleSelections(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if (b != multipleMode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            multipleMode = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
            ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            if (peer != null) {
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   747
                peer.setMultipleMode(b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * Gets the index of the item that was last made visible by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * the method <code>makeVisible</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * @return      the index of the item that was last made visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * @see         #makeVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    public int getVisibleIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        return visibleIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * Makes the item at the specified index visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * @param       index    the position of the item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * @see         #getVisibleIndex
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    public synchronized void makeVisible(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        visibleIndex = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            peer.makeVisible(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * Gets the preferred dimensions for a list with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * number of rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * @param      rows    number of rows in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @return     the preferred dimensions for displaying this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     *             given that the specified number of rows must be visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @see        java.awt.Component#getPreferredSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   782
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    public Dimension getPreferredSize(int rows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        return preferredSize(rows);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   789
     * Returns the preferred size of this component
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   790
     * assuming it has the specified number of rows.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   791
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   792
     * @param  rows the number of rows
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   793
     * @return the preferred dimensions for displaying this list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * replaced by <code>getPreferredSize(int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    public Dimension preferredSize(int rows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            return (peer != null) ?
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   802
                       peer.getPreferredSize(rows) :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                       super.preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * Gets the preferred size of this scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @return     the preferred dimensions for displaying this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * @see        java.awt.Component#getPreferredSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   811
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        return preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * replaced by <code>getPreferredSize()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    public Dimension preferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            return (rows > 0) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                       preferredSize(rows) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                       super.preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20451
diff changeset
   831
     * Gets the minimum dimensions for a list with the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * number of rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * @param      rows    number of rows in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * @return     the minimum dimensions for displaying this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *             given that the specified number of rows must be visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * @see        java.awt.Component#getMinimumSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   837
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    public Dimension getMinimumSize(int rows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        return minimumSize(rows);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   844
     * Returns the minimum dimensions for the list
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   845
     * with the specified number of rows.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   846
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   847
     * @param  rows the number of rows in the list
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   848
     * @return the minimum dimensions for displaying this list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * replaced by <code>getMinimumSize(int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    public Dimension minimumSize(int rows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            return (peer != null) ?
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   857
                       peer.getMinimumSize(rows) :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                       super.minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * Determines the minimum size of this scrolling list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * @return       the minimum dimensions needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     *                        to display this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * @see          java.awt.Component#getMinimumSize()
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   867
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        return minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * replaced by <code>getMinimumSize()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public Dimension minimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            return (rows > 0) ? minimumSize(rows) : super.minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * Adds the specified item listener to receive item events from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * this list.  Item events are sent in response to user input, but not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * in response to calls to <code>select</code> or <code>deselect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * If listener <code>l</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * @param         l the item listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @see           #removeItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * @see           #getItemListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @see           #select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * @see           #deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * @see           java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * @see           java.awt.event.ItemListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   900
     * @since         1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    public synchronized void addItemListener(ItemListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        itemListener = AWTEventMulticaster.add(itemListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        newEventsOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * Removes the specified item listener so that it no longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * receives item events from this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * If listener <code>l</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * @param           l the item listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * @see             #addItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * @see             #getItemListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @see             java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     * @see             java.awt.event.ItemListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   923
     * @since           1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    public synchronized void removeItemListener(ItemListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        itemListener = AWTEventMulticaster.remove(itemListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * Returns an array of all the item listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * registered on this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * @return all of this list's <code>ItemListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     *         or an empty array if no item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * @see             #addItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * @see             #removeItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * @see             java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * @see             java.awt.event.ItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    public synchronized ItemListener[] getItemListeners() {
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
   947
        return getListeners(ItemListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * Adds the specified action listener to receive action events from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * this list. Action events occur when a user double-clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * on a list item or types Enter when the list has the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * If listener <code>l</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * @param         l the action listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * @see           #removeActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * @see           #getActionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * @see           java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * @see           java.awt.event.ActionListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   966
     * @since         1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    public synchronized void addActionListener(ActionListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        actionListener = AWTEventMulticaster.add(actionListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        newEventsOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * Removes the specified action listener so that it no longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * receives action events from this list. Action events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * occur when a user double-clicks on a list item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * If listener <code>l</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * @param           l     the action listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * @see             #addActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @see             #getActionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * @see             java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * @see             java.awt.event.ActionListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
   990
     * @since           1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    public synchronized void removeActionListener(ActionListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        actionListener = AWTEventMulticaster.remove(actionListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * Returns an array of all the action listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * registered on this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @return all of this list's <code>ActionListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     *         or an empty array if no action
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @see             #addActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * @see             #removeActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * @see             java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     * @see             java.awt.event.ActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    public synchronized ActionListener[] getActionListeners() {
11813
643f5bef6ab4 7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents: 5506
diff changeset
  1014
        return getListeners(ActionListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * Returns an array of all the objects currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * as <code><em>Foo</em>Listener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * upon this <code>List</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * <code><em>Foo</em>Listener</code>s are registered using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * <code>add<em>Foo</em>Listener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * You can specify the <code>listenerType</code> argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * with a class literal, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * <code><em>Foo</em>Listener.class</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * For example, you can query a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * <code>List</code> <code>l</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * for its item listeners with the following code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * <pre>ItemListener[] ils = (ItemListener[])(l.getListeners(ItemListener.class));</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * If no such listeners exist, this method returns an empty array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @param listenerType the type of listeners requested; this parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     *          should specify an interface that descends from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     *          <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * @return an array of all objects registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     *          <code><em>Foo</em>Listener</code>s on this list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     *          or an empty array if no such
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     *          listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * @exception ClassCastException if <code>listenerType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     *          doesn't specify a class or interface that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *          <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * @see #getItemListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        EventListener l = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        if  (listenerType == ActionListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            l = actionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        } else if  (listenerType == ItemListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            l = itemListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            return super.getListeners(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        return AWTEventMulticaster.getListeners(l, listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    // REMIND: remove when filtering is done at lower level
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
    boolean eventEnabled(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        switch(e.id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
          case ActionEvent.ACTION_PERFORMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
            if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                actionListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
          case ItemEvent.ITEM_STATE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                itemListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        return super.eventEnabled(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * Processes events on this scrolling list. If an event is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * an instance of <code>ItemEvent</code>, it invokes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * <code>processItemEvent</code> method. Else, if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     * event is an instance of <code>ActionEvent</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * it invokes <code>processActionEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     * If the event is not an item event or an action event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
     * it invokes <code>processEvent</code> on the superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     * <p>Note that if the event parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * @param        e the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * @see          java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * @see          java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * @see          #processActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * @see          #processItemEvent
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
  1100
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    protected void processEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        if (e instanceof ItemEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            processItemEvent((ItemEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        } else if (e instanceof ActionEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            processActionEvent((ActionEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        super.processEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * Processes item events occurring on this list by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     * dispatching them to any registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     * <code>ItemListener</code> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     * This method is not called unless item events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
     * enabled for this component. Item events are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * when one of the following occurs:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
  1121
     * <ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * <li>An <code>ItemListener</code> object is registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * via <code>addItemListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * <li>Item events are enabled via <code>enableEvents</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * <p>Note that if the event parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * @param       e the item event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * @see         java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * @see         java.awt.event.ItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     * @see         #addItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * @see         java.awt.Component#enableEvents
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
  1135
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    protected void processItemEvent(ItemEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        ItemListener listener = itemListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        if (listener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            listener.itemStateChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     * Processes action events occurring on this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     * by dispatching them to any registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * <code>ActionListener</code> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * This method is not called unless action events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * enabled for this component. Action events are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * when one of the following occurs:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
  1152
     * <ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * <li>An <code>ActionListener</code> object is registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * via <code>addActionListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * <li>Action events are enabled via <code>enableEvents</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * <p>Note that if the event parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * @param       e the action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * @see         java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     * @see         java.awt.event.ActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * @see         #addActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * @see         java.awt.Component#enableEvents
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21957
diff changeset
  1166
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    protected void processActionEvent(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        ActionListener listener = actionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
        if (listener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
            listener.actionPerformed(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * Returns the parameter string representing the state of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * scrolling list. This string is useful for debugging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * @return    the parameter string of this scrolling list
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        return super.paramString() + ",selected=" + getSelectedItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1185
     * Deletes the list items in the specified index range.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1186
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1187
     * @param  start the beginning index of the range to delete
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1188
     * @param  end the ending index of the range to delete
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
     * Not for public use in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     * This method is expected to be retained only as a package
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * private method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
    public synchronized void delItems(int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        for (int i = end; i >= start; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
            items.removeElementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
            peer.delItems(start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * Serialization support.  Since the value of the selected
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20451
diff changeset
  1207
     * field isn't necessarily up to date, we sync it up with the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     * peer before serializing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * The <code>List</code> component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     * Serialized Data Version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    private int listSerializedDataVersion = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * Writes default serializable fields to stream.  Writes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * a list of serializable <code>ItemListeners</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     * and <code>ActionListeners</code> as optional data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * The non-serializable listeners are detected and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
     * no attempt is made to serialize them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
     * @serialData <code>null</code> terminated sequence of 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     *  or more pairs; the pair consists of a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
     *  and an <code>Object</code>; the <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     *  indicates the type of object and is one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     *  following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
     *  <code>itemListenerK</code> indicating an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     *    <code>ItemListener</code> object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     *  <code>actionListenerK</code> indicating an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     *    <code>ActionListener</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     * @param s the <code>ObjectOutputStream</code> to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
     * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     * @see java.awt.Component#itemListenerK
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * @see java.awt.Component#actionListenerK
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * @see #readObject(ObjectInputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    private void writeObject(ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
      throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
      synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        ListPeer peer = (ListPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
          selected = peer.getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
      s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
      AWTEventMulticaster.save(s, itemListenerK, itemListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
      AWTEventMulticaster.save(s, actionListenerK, actionListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
      s.writeObject(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     * Reads the <code>ObjectInputStream</code> and if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * isn't <code>null</code> adds a listener to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * both item events and action events (as specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     * by the key stored in the stream) fired by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
     * <code>List</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
     * Unrecognized keys or values will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * @param s the <code>ObjectInputStream</code> to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     *   <code>GraphicsEnvironment.isHeadless</code> returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     *   <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
     * @see #removeItemListener(ItemListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * @see #addItemListener(ItemListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * @see #writeObject(ObjectOutputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
      GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
      s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
      Object keyOrNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
      while(null != (keyOrNull = s.readObject())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        String key = ((String)keyOrNull).intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        if (itemListenerK == key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
          addItemListener((ItemListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        else if (actionListenerK == key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
          addActionListener((ActionListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        else // skip value for unrecognized key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
          s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     * Gets the <code>AccessibleContext</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * <code>List</code>. For lists, the <code>AccessibleContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     * takes the form of an <code>AccessibleAWTList</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * A new <code>AccessibleAWTList</code> instance is created, if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
     * @return an <code>AccessibleAWTList</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
     *         <code>AccessibleContext</code> of this <code>List</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            accessibleContext = new AccessibleAWTList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     * <code>List</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * Java Accessibility API appropriate to list user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
    protected class AccessibleAWTList extends AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        implements AccessibleSelection, ItemListener, ActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        private static final long serialVersionUID = 7924617370136012829L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1333
        /**
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1334
         * Constructs new {@code AccessibleAWTList}
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1335
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        public AccessibleAWTList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
            List.this.addActionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
            List.this.addItemListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
        public void actionPerformed(ActionEvent event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        public void itemStateChanged(ItemEvent event)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
         * Get the state set of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
         * @return an instance of AccessibleState containing the current state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
         * of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
            if (List.this.isMultipleMode())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
                states.add(AccessibleState.MULTISELECTABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
            return AccessibleRole.LIST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
         * Returns the Accessible child contained at the local coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
         * Point, if one exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
         * @return the Accessible at the specified location, if it exists
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
        public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            return null; // fredxFIXME Not implemented yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
         * Returns the number of accessible children in the object.  If all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
         * of the children of this object implement Accessible, than this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
         * method should return the number of children of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
         * @return the number of accessible children in the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            return List.this.getItemCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
         * Return the nth Accessible child of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
         * @return the nth Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
            synchronized(List.this)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                if (i >= List.this.getItemCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                    return new AccessibleAWTListChild(List.this, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
         * Get the AccessibleSelection associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
         * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
         * return this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
         * AccessibleSelection interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
         * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
        public AccessibleSelection getAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    // AccessibleSelection methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
         * Returns the number of items currently selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
         * If no items are selected, the return value will be 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
         * @return the number of items currently selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
         public int getAccessibleSelectionCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
             return List.this.getSelectedIndexes().length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
         * Returns an Accessible representing the specified selected item
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
         * in the object.  If there isn't a selection, or there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
         * fewer items selected than the integer passed in, the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
         * value will be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
         * @param i the zero-based index of selected items
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
         * @return an Accessible containing the selected item
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
         public Accessible getAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
             synchronized(List.this)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
                 int len = getAccessibleSelectionCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                 if (i < 0 || i >= len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                     return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                 } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                     return getAccessibleChild(List.this.getSelectedIndexes()[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
         * Returns true if the current child of this object is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
         * @param i the zero-based index of the child in this Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
         * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        public boolean isAccessibleChildSelected(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
            return List.this.isIndexSelected(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
         * Adds the specified selected item in the object to the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
         * selection.  If the object supports multiple selections,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
         * the specified item is added to any existing selection, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
         * it replaces any existing selection in the object.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
         * specified item is already selected, this method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
         * @param i the zero-based index of selectable items
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
         public void addAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
             List.this.select(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
         * Removes the specified selected item in the object from the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
         * selection.  If the specified item isn't currently selected, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
         * method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
         * @param i the zero-based index of selectable items
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
         public void removeAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
             List.this.deselect(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
         * Clears the selection in the object, so that nothing in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
         * object is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
         public void clearAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
             synchronized(List.this)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
                 int selectedIndexes[] = List.this.getSelectedIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
                 if (selectedIndexes == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
                     return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
                 for (int i = selectedIndexes.length - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
                     List.this.deselect(selectedIndexes[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
         * Causes every selected item in the object to be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
         * if the object supports multiple selections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
         public void selectAllAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
             synchronized(List.this)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
                 for (int i = List.this.getItemCount() - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
                     List.this.select(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
       /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
        * This class implements accessibility support for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
        * List children.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
        * Java Accessibility API appropriate to list children
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
        * user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
        * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
        protected class AccessibleAWTListChild extends AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
            implements Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
             * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
            private static final long serialVersionUID = 4412022926028300317L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        // [[[FIXME]]] need to finish implementing this!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
            private List parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
            private int  indexInParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1537
            /**
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1538
             * Constructs new {@code AccessibleAWTListChild} with the given
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1539
             * parent {@code List} and 0-based index of this object in the parent.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1540
             *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1541
             * @param  parent the parent {@code List}
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1542
             * @param  indexInParent the index in the parent
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1543
             */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
            public AccessibleAWTListChild(List parent, int indexInParent)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
                this.parent = parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
                this.setAccessibleParent(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
                this.indexInParent = indexInParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
            // required Accessible methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
          /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
           * Gets the AccessibleContext for this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
           * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
           * return this object, which acts as its own AccessibleContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
           *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
           * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
           */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
            public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
            // required AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
             * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
             * @return an instance of AccessibleRole describing the role of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
             * the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
             * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
            public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
                return AccessibleRole.LIST_ITEM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
             * Get the state set of this object.  The AccessibleStateSet of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
             * object is composed of a set of unique AccessibleState's.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
             * change in the AccessibleStateSet of an object will cause a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
             * PropertyChangeEvent to be fired for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
             * ACCESSIBLE_STATE_PROPERTY property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
             * @return an instance of AccessibleStateSet containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
             * current state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
             * @see AccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
             * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
             * @see #addPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
            public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
                AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
                if (parent.isIndexSelected(indexInParent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
                    states.add(AccessibleState.SELECTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
                return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
             * Gets the locale of the component. If the component does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
             * have a locale, then the locale of its parent is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
             * @return This component's locale.  If this component does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
             * a locale, the locale of its parent is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
             * @exception IllegalComponentStateException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
             * If the Component does not have its own locale and has not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
             * been added to a containment hierarchy such that the locale can
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
             * be determined from the containing parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
            public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
                return parent.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
             * Get the 0-based index of this object in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
             * @return the 0-based index of this object in its parent; -1 if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
             * this object does not have an accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
             * @see #getAccessibleParent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
             * @see #getAccessibleChildrenCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
             * @see #getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
            public int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
                return indexInParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
             * Returns the number of accessible children of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
             * @return the number of accessible children of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
            public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
                return 0;       // list elements can't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
             * Return the specified Accessible child of the object.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
             * Accessible children of an Accessible object are zero-based,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
             * so the first child of an Accessible child is at index 0, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
             * second child is at index 1, and so on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
             * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
             * @return the Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
             * @see #getAccessibleChildrenCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
            public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
                return null;    // list elements can't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
            // AccessibleComponent delegatation to parent List
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
             * Get the background color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
             * @return the background color, if supported, of the object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
             * otherwise, null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
             * @see #setBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
            public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
                return parent.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
             * Set the background color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
             * @param c the new Color for the background
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
             * @see #setBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
            public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
                parent.setBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
             * Get the foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
             * @return the foreground color, if supported, of the object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
             * otherwise, null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
             * @see #setForeground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
            public Color getForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
                return parent.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
             * Set the foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
             * @param c the new Color for the foreground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
             * @see #getForeground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
            public void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
                parent.setForeground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
             * Get the Cursor of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
             * @return the Cursor, if supported, of the object; otherwise, null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
             * @see #setCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
            public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
                return parent.getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
             * Set the Cursor of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
             * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
             * The method may have no visual effect if the Java platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
             * implementation and/or the native system do not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
             * changing the mouse cursor shape.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
             * @param cursor the new Cursor for the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
             * @see #getCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
            public void setCursor(Cursor cursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
                parent.setCursor(cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
             * Get the Font of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
             * @return the Font,if supported, for the object; otherwise, null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
             * @see #setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
            public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
                return parent.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
             * Set the Font of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
             * @param f the new Font for the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
             * @see #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
            public void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
                parent.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
             * Get the FontMetrics of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
             * @param f the Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
             * @return the FontMetrics, if supported, the object; otherwise, null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
             * @see #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
            public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
                return parent.getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
             * Determine if the object is enabled.  Objects that are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
             * will also have the AccessibleState.ENABLED state set in their
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
             * AccessibleStateSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
             * @return true if object is enabled; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
             * @see #setEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
             * @see AccessibleContext#getAccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
             * @see AccessibleState#ENABLED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
             * @see AccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
            public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
                return parent.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
             * Set the enabled state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
             * @param b if true, enables this object; otherwise, disables it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
             * @see #isEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
            public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
                parent.setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
             * Determine if the object is visible.  Note: this means that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
             * object intends to be visible; however, it may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
             * showing on the screen because one of the objects that this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
             * is contained by is currently not visible.  To determine if an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
             * object is showing on the screen, use isShowing().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
             * <p>Objects that are visible will also have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
             * AccessibleState.VISIBLE state set in their AccessibleStateSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
             * @return true if object is visible; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
             * @see #setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
             * @see AccessibleContext#getAccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
             * @see AccessibleState#VISIBLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
             * @see AccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
            public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
                // [[[FIXME]]] needs to work like isShowing() below
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
                // return parent.isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
             * Set the visible state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
             * @param b if true, shows this object; otherwise, hides it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
             * @see #isVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
            public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
                // [[[FIXME]]] should scroll to item to make it show!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
                parent.setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
             * Determine if the object is showing.  This is determined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
             * checking the visibility of the object and visibility of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
             * object ancestors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
             * Note: this will return true even if the object is obscured
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
             * by another (for example, it to object is underneath a menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
             * that was pulled down).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
             * @return true if object is showing; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
            public boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
                // [[[FIXME]]] only if it's showing!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
                // return parent.isShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
             * Checks whether the specified point is within this object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
             * bounds, where the point's x and y coordinates are defined to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
             * be relative to the coordinate system of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
             * @param p the Point relative to the coordinate system of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
             * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
             * @return true if object contains Point; otherwise false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
             * @see #getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
            public boolean contains(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
                // [[[FIXME]]] - only if p is within the list element!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
                // return parent.contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
             * Returns the location of the object on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
             * @return location of object on screen; null if this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
             * is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
             * @see #getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
             * @see #getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
            public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
                // [[[FIXME]]] sigh
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
             * Gets the location of the object relative to the parent in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
             * form of a point specifying the object's top-left corner in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
             * screen's coordinate space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
             * @return An instance of Point representing the top-left corner of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
             * the objects's bounds in the coordinate space of the screen; null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
             * if this object or its parent are not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
             * @see #getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
             * @see #getLocationOnScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
            public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
                // [[[FIXME]]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
             * Sets the location of the object relative to the parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
             * @param p the new position for the top-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
             * @see #getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
            public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
                // [[[FIXME]]] maybe - can simply return as no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
             * Gets the bounds of this object in the form of a Rectangle object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
             * The bounds specify this object's width, height, and location
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
             * relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
             * @return A rectangle indicating this component's bounds; null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
             * this object is not on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
             * @see #contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
            public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
                // [[[FIXME]]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
             * Sets the bounds of this object in the form of a Rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
             * object.  The bounds specify this object's width, height, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
             * location relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
             * @param r rectangle indicating this component's bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
             * @see #getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
            public void setBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
                // no-op; not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
             * Returns the size of this object in the form of a Dimension
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
             * object.  The height field of the Dimension object contains this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
             * objects's height, and the width field of the Dimension object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
             * contains this object's width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
             * @return A Dimension object that indicates the size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
             * component; null if this object is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
             * @see #setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
            public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
                // [[[FIXME]]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
             * Resizes this object so that it has width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
             * @param d - The dimension specifying the new size of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
             * @see #getSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
            public void setSize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
                // not supported; no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
             * Returns the <code>Accessible</code> child, if one exists,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
             * contained at the local coordinate <code>Point</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
             * @param p the point relative to the coordinate system of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
             *     object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
             * @return the <code>Accessible</code>, if it exists,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
             *     at the specified location; otherwise <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
            public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
                return null;    // object cannot have children!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
             * Returns whether this object can accept focus or not.   Objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
             * that can accept focus will also have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
             * <code>AccessibleState.FOCUSABLE</code> state set in their
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
             * <code>AccessibleStateSet</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
             * @return true if object can accept focus; otherwise false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
             * @see AccessibleContext#getAccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
             * @see AccessibleState#FOCUSABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
             * @see AccessibleState#FOCUSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
             * @see AccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
            public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
                return false;   // list element cannot receive focus!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
             * Requests focus for this object.  If this object cannot accept
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
             * focus, nothing will happen.  Otherwise, the object will attempt
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
             * to take focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
             * @see #isFocusTraversable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
            public void requestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
                // nothing to do; a no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
             * Adds the specified focus listener to receive focus events from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
             * this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
             * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
             * @see #removeFocusListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
            public void addFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
                // nothing to do; a no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
             * Removes the specified focus listener so it no longer receives
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
             * focus events from this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
             * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
             * @see #addFocusListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
            public void removeFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                // nothing to do; a no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
        } // inner class AccessibleAWTListChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
    } // inner class AccessibleAWTList
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
}