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