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