001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package javax.microedition.lcdui;
028:
029: /**
030: * A <code>Screen</code> containing list of choices. Most of its
031: * behavior is common with
032: * class {@link ChoiceGroup ChoiceGroup}, and their common API. The
033: * different <code>List</code> types in particular, are defined in
034: * interface {@link Choice
035: * Choice}. When a <code>List</code> is present on the display, the
036: * user can interact with
037: * it by selecting elements and possibly by traversing and scrolling among
038: * them. Traversing and scrolling operations do not cause application-visible
039: * events. The system notifies the application only when a {@link Command
040: * Command} is invoked by notifying its {@link CommandListener}. The
041: * <code>List</code>
042: * class also supports a select command that may be invoked specially
043: * depending upon the capabilities of the device.
044: *
045: * <p>The notion of a <em>select</em> operation on a <code>List</code>
046: * element is central
047: * to the user's interaction with the <code>List</code>. On devices
048: * that have a dedicated
049: * hardware "select" or "go" key, the select
050: * operation is implemented with
051: * that key. Devices that do not have a dedicated key must provide another
052: * means to do the select operation, for example, using a soft key. The
053: * behavior of the select operation within the different types of lists is
054: * described in the following sections.</p>
055: *
056: * <p><code>List</code> objects may be created with <code>Choice</code> types of
057: * {@link Choice#EXCLUSIVE}, {@link Choice#MULTIPLE}, and
058: * {@link Choice#IMPLICIT}. The <code>Choice</code> type {@link Choice#POPUP}
059: * is not allowed on <code>List</code> objects.</p>
060: *
061: * <h3>Selection in <code>EXCLUSIVE</code> and <code>MULTIPLE</code> Lists</h3>
062: *
063: * <p>The select operation is not associated with a
064: * <code>Command</code> object, so the
065: * application has no means of setting a label for it or being notified when
066: * the operation is performed. In <code>Lists</code> of type
067: * <code>EXCLUSIVE</code>, the select
068: * operation selects the target element and deselects the previously selected
069: * element. In <code>Lists</code> of type <code>MULTIPLE</code>, the
070: * select operation toggles the
071: * selected state of the target element, leaving the selected state of other
072: * elements unchanged. Devices that implement the select operation using a
073: * soft key will need to provide a label for it. The label should be something
074: * similar to "Select" for <code>Lists</code> of type
075: * <code>EXCLUSIVE</code>, and it should be something
076: * similar to "Mark" or "Unmark" for
077: * <code>Lists</code> of type <code>MULTIPLE</code>.</p>
078: *
079: * <h3>Selection in <code>IMPLICIT</code> Lists</h3>
080: *
081: * <p>The select operation is associated with a <code>Command</code>
082: * object referred to as
083: * the <em>select command</em>. When the user performs the select operation,
084: * the system will invoke the select command by notifying the
085: * <code>List's</code> {@link
086: * CommandListener CommandListener}. The default select command is the
087: * system-provided command <code>SELECT_COMMAND</code>. The select
088: * command may be modified
089: * by the application through use of the {@link #setSelectCommand(Command
090: * command) setSelectCommand} method. Devices that implement the select
091: * operation using a soft key will use the label from the select command. If
092: * the select command is <code>SELECT_COMMAND</code>, the device may
093: * choose to provide its
094: * own label instead of using the label attribute of
095: * <code>SELECT_COMMAND</code>.
096: * Applications should generally provide their own select command to replace
097: * <code>SELECT_COMMAND</code>. This allows applications to provide a
098: * meaningful label,
099: * instead of relying on the one provided by the system for
100: * <code>SELECT_COMMAND</code>.
101: * The implementation must <em>not</em> invoke the select command if there are
102: * no elements in the <code>List</code>, because if the
103: * <code>List</code> is empty the selection does
104: * not exist. In this case the implementation should remove or disable the
105: * select command if it would appear explicitly on a soft button or in a menu.
106: * Other commands can be invoked normally when the <code>List</code>
107: * is empty.</p>
108: *
109: * <h3>Use of <code>IMPLICIT</code> Lists</h3>
110: *
111: * <p> <code>IMPLICIT</code> <code>Lists</code> can be used to
112: * construct menus by providing operations
113: * as <code>List</code> elements. The application provides a
114: * <code>Command</code> that is used to
115: * select a <code>List</code> element and then defines this
116: * <code>Command</code> to be used as the
117: * select command. The application must also register a
118: * <code>CommandListener</code> that
119: * is called when the user selects or activates the <code>Command</code>:</p>
120: *
121: * <TABLE BORDER="2">
122: * <TR>
123: * <TD ROWSPAN="1" COLSPAN="1">
124: * <pre><code>
125: * String[] elements = { ... }; //Menu items as List elements
126: * List menuList = new List("Menu", List.IMPLICIT, elements, null);
127: * Command selectCommand = new Command("Open", Command.ITEM, 1);
128: * menuList.setSelectCommand(selectCommand);
129: * menuList.setCommandListener(...); </code></pre>
130: * </TD>
131: * </TR>
132: * </TABLE>
133: *
134: * <p>The listener can query the <code>List</code> to determine which
135: * element is selected
136: * and then perform the corresponding action. Note that setting a command as
137: * the select command adds it to the <code>List</code> as a side effect.</p>
138: *
139: * <p> The select command should be considered as a <em>default operation</em>
140: * that takes place when a select key is pressed. For example, a
141: * <code>List</code>
142: * displaying email headers might have three operations: read, reply, and
143: * delete. Read is considered to be the default operation. </p>
144: *
145: * <TABLE BORDER="2">
146: * <TR>
147: * <TD ROWSPAN="1" COLSPAN="1">
148: * <pre><code>
149: * List list = new List("Email", List.IMPLICIT, headers);
150: * readCommand = new Command("Read", Command.ITEM, 1);
151: * replyCommand = new Command("Reply", Command.ITEM, 2);
152: * deleteCommand = new Command("Delete", Command.ITEM, 3);
153: * list.setSelectCommand(readCommand);
154: * list.addCommand(replyCommand);
155: * list.addCommand(deleteCommand);
156: * list.setCommandListener(...); </code></pre>
157: * </TD>
158: * </TR>
159: * </TABLE>
160: * <p>On a device with a dedicated select key, pressing this key will invoke
161: * <code>readCommand</code>. On a device without a select key, the user is
162: * still able to invoke the read command, since it is also provided as an
163: * ordinary <code>Command</code>.</p>
164: *
165: * <p> It should be noted that this kind of default operation must be used
166: * carefully, and the usability of the resulting user interface must always
167: * kept in mind. The default operation should always be the most intuitive
168: * operation on a particular List. </p>
169: *
170: * @since MIDP 1.0
171: */
172:
173: public class List extends Screen implements Choice {
174:
175: /**
176: * The default select command for <code>IMPLICIT</code> <code>Lists</code>.
177: * Applications using an <code>IMPLICIT</code> <code>List</code>
178: * should set their own select command
179: * using
180: * {@link #setSelectCommand(Command command) setSelectCommand}.
181: *
182: * <p>
183: * The field values of <code>SELECT_COMMAND</code> are:<br>
184: * - <code>label = ""</code> (an empty string)<br>
185: * - <code>type = SCREEN</code><br>
186: * - <code>priority = 0</code><br>
187: * </p>
188: * <p>(It would be more appropriate if the type were
189: * <code>ITEM</code>, but the type of
190: * <code>SCREEN</code> is retained for historical purposes.)</p>
191: * <p>
192: * The application should not use these values for recognizing
193: * the <code>SELECT_COMMAND</code>. Instead, object identities of
194: * the <code>Command</code> and
195: * <code>Displayable</code> (<code>List</code>) should be used.
196: * </p>
197: *
198: * <p><code>SELECT_COMMAND</code> is treated as an ordinary
199: * <code>Command</code> if it is used with other <code>Displayable</code>
200: * types.</p>
201: */
202: public final static Command SELECT_COMMAND = new Command("",
203: Command.SCREEN, 0);
204:
205: // constructors //
206:
207: /**
208: * Creates a new, empty <code>List</code>, specifying its title
209: * and the type of the
210: * list.
211: * @param title the screen's title (see {@link Displayable Displayable})
212: * @param listType one of <code>IMPLICIT</code>, <code>EXCLUSIVE</code>,
213: * or <code>MULTIPLE</code>
214: * @throws IllegalArgumentException if <code>listType</code> is not
215: * one of
216: * <code>IMPLICIT</code>,
217: * <code>EXCLUSIVE</code>, or <code>MULTIPLE</code>
218: * @see Choice
219: */
220: public List(String title, int listType) {
221: this (title, listType, new String[] {}, new Image[] {});
222: }
223:
224: /**
225: * Creates a new <code>List</code>, specifying its title, the type
226: * of the <code>List</code>, and
227: * an array of <code>Strings</code> and <code>Images</code> to be
228: * used as its initial contents.
229: *
230: * <p>The <code>stringElements</code> array must be non-null and
231: * every array element
232: * must also be non-null. The length of the
233: * <code>stringElements</code> array
234: * determines the number of elements in the <code>List</code>.
235: * The <code>imageElements</code> array
236: * may be <code>null</code> to indicate that the <code>List</code>
237: * elements have no images. If the
238: * <code>imageElements</code> array is non-null, it must be the
239: * same length as the
240: * <code>stringElements</code> array. Individual elements of the
241: * <code>imageElements</code> array
242: * may be <code>null</code> in order to indicate the absence of an
243: * image for the
244: * corresponding <code>List</code> element. Non-null elements of the
245: * <code>imageElements</code> array may refer to mutable or
246: * immutable images.</p>
247: *
248: * @param title the screen's title (see {@link Displayable Displayable})
249: * @param listType one of <code>IMPLICIT</code>, <code>EXCLUSIVE</code>,
250: * or <code>MULTIPLE</code>
251: * @param stringElements set of strings specifying the string parts of the
252: * <code>List</code> elements
253: * @param imageElements set of images specifying the image parts of
254: * the <code>List</code> elements
255: *
256: * @throws NullPointerException if <code>stringElements</code> is
257: * <code>null</code>
258: * @throws NullPointerException if the <code>stringElements</code>
259: * array contains any null elements
260: * @throws IllegalArgumentException if the <code>imageElements</code>
261: * array is non-null
262: * and has a different length from the <code>stringElements</code> array
263: * @throws IllegalArgumentException if <code>listType</code> is not one
264: * of <code>IMPLICIT</code>,
265: * <code>EXCLUSIVE</code>, or <code>MULTIPLE</code>
266: *
267: * @see Choice#EXCLUSIVE
268: * @see Choice#MULTIPLE
269: * @see Choice#IMPLICIT
270: */
271: public List(String title, int listType, String[] stringElements,
272: Image[] imageElements) {
273:
274: super (title);
275:
276: if (!(listType == IMPLICIT || listType == EXCLUSIVE || listType == MULTIPLE)) {
277: throw new IllegalArgumentException();
278: }
279:
280: synchronized (Display.LCDUILock) {
281:
282: cg = new ChoiceGroup(null, listType, stringElements,
283: imageElements, true);
284: cg.lSetOwner(this );
285:
286: displayableLF = listLF = LFFactory.getFactory().getListLF(
287: this );
288: }
289: }
290:
291: // *****************************************************
292: // Public methods
293: // *****************************************************
294: /**
295: * Gets the number of elements in the <code>List</code>.
296: * @return the number of elements in the <code>List</code>
297: */
298: public int size() {
299: return cg.size();
300: }
301:
302: /**
303: * Gets the <code>String</code> part of the element referenced by
304: * <code>elementNum</code>.
305: *
306: * @param elementNum the index of the element to be queried
307: * @return the string part of the element
308: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
309: * @see #getImage(int)
310: */
311: public String getString(int elementNum) {
312: return cg.getString(elementNum);
313: }
314:
315: /**
316: * Gets the <code>Image</code> part of the element referenced by
317: * <code>elementNum</code>.
318: *
319: * @param elementNum the number of the element to be queried
320: * @return the image part of the element, or <code>null</code>
321: * if there is no image
322: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
323: * @see #getString(int)
324: */
325: public Image getImage(int elementNum) {
326: return cg.getImage(elementNum);
327: }
328:
329: /**
330: * Appends an element to the <code>List</code>.
331: *
332: * @param stringPart the string part of the element to be added
333: * @param imagePart the image part of the element to be added, or
334: * <code>null</code> if there is no image part
335: * @return the assigned index of the element
336: * @throws NullPointerException if <code>stringPart</code> is
337: * <code>null</code>
338: */
339: public int append(String stringPart, Image imagePart) {
340: return cg.append(stringPart, imagePart);
341: }
342:
343: /**
344: * Inserts an element into the <code>List</code> just prior to
345: * the element specified.
346: *
347: * @param elementNum the index of the element where insertion is to occur
348: * @param stringPart the string part of the element to be inserted
349: * @param imagePart the image part of the element to be inserted,
350: * or <code>null</code> if there is no image part
351: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
352: * @throws NullPointerException if <code>stringPart</code> is
353: * <code>null</code>
354: */
355: public void insert(int elementNum, String stringPart,
356: Image imagePart) {
357: cg.insert(elementNum, stringPart, imagePart);
358: }
359:
360: /**
361: * Deletes the element referenced by <code>elementNum</code>.
362: *
363: * @param elementNum the index of the element to be deleted
364: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
365: */
366: public void delete(int elementNum) {
367: cg.delete(elementNum);
368: }
369:
370: /**
371: * Deletes all elements from this List.
372: */
373: public void deleteAll() {
374: cg.deleteAll();
375: }
376:
377: /**
378: * Sets the <code>String</code> and <code>Image</code> parts of the
379: * element referenced by <code>elementNum</code>,
380: * replacing the previous contents of the element.
381: *
382: * @param elementNum the index of the element to be set
383: * @param stringPart the string part of the new element
384: * @param imagePart the image part of the element, or <code>null</code>
385: * if there is no image part
386: *
387: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
388: * @throws NullPointerException if <code>stringPart</code> is
389: * <code>null</code>
390: */
391: public void set(int elementNum, String stringPart, Image imagePart) {
392: cg.set(elementNum, stringPart, imagePart);
393: }
394:
395: /**
396: * Gets a boolean value indicating whether this element is selected.
397: *
398: * @param elementNum index to element to be queried
399: *
400: * @return selection state of the element
401: *
402: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
403: */
404: public boolean isSelected(int elementNum) {
405: return cg.isSelected(elementNum);
406: }
407:
408: /**
409: * Returns the index number of an element in the <code>List</code>
410: * that is selected.
411: *
412: * @return index of selected element, or <code>-1</code> if none
413: * @see #setSelectedIndex
414: */
415: public int getSelectedIndex() {
416: return cg.getSelectedIndex();
417: }
418:
419: /**
420: * Queries the state of a <code>List</code> and returns the
421: * state of all elements
422: * in the
423: * boolean array
424: * <code>selectedArray_return</code>.
425: *
426: * @param selectedArray_return array to contain the results
427: *
428: * @return the number of selected elements in the <code>Choice</code>
429: *
430: * @throws IllegalArgumentException if <code>selectedArray_return</code>
431: * is shorter than the size of the List
432: * @throws NullPointerException if <code>selectedArray_return</code>
433: * is <code>null</code>
434: * @see #setSelectedFlags
435: */
436: public int getSelectedFlags(boolean[] selectedArray_return) {
437: return cg.getSelectedFlags(selectedArray_return);
438: }
439:
440: /**
441: * Sets the selected state of an element.
442: *
443: * @param elementNum the index of the element, starting from zero
444: * @param selected the state of the element, where <code>true</code> means
445: * selected and <code>false</code> means not selected
446: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
447: * @see #getSelectedIndex
448: */
449: public void setSelectedIndex(int elementNum, boolean selected) {
450: cg.setSelectedIndex(elementNum, selected);
451: }
452:
453: /**
454: * Sets the selected state of all elements of the <code>List</code>.
455: *
456: * @param selectedArray an array in which the method collect
457: * the selection status
458: * @throws IllegalArgumentException if <code>selectedArray</code> is
459: * shorter than the size of the <code>List</code>
460: * @throws NullPointerException if <code>selectedArray</code> is
461: * <code>null</code>
462: * @see #getSelectedFlags
463: */
464: public void setSelectedFlags(boolean[] selectedArray) {
465: cg.setSelectedFlags(selectedArray);
466: }
467:
468: /**
469: * The same as {@link Displayable#removeCommand Displayable.removeCommand}
470: * but with the following additional semantics.
471: *
472: * <p>If the command to be removed happens to be the select command, the
473: * <code>List</code> is set to have no select command, and the command is
474: * removed from the <code>List</code>.</p>
475: *
476: * <p>The following code: </P>
477: * <TABLE BORDER="2">
478: * <TR>
479: * <TD ROWSPAN="1" COLSPAN="1">
480: * <pre><code>
481: * // Command c is the select command on List list
482: * list.removeCommand(c); </code></pre>
483: * </TD>
484: * </TR>
485: * </TABLE>
486: * <P>
487: * is equivalent to the following code: </P>
488: * <TABLE BORDER="2">
489: * <TR>
490: * <TD ROWSPAN="1" COLSPAN="1">
491: * <pre><code>
492: * // Command c is the select command on List list
493: * list.setSelectCommand(null);
494: * list.removeCommand(c); </code></pre>
495: * </TD>
496: * </TR>
497: * </TABLE>
498: * @param cmd the command to be removed
499: *
500: */
501: public void removeCommand(Command cmd) {
502: synchronized (Display.LCDUILock) {
503: int i = super .removeCommandImpl(cmd);
504: if (cmd == selectCommand) {
505: selectCommand = null;
506: }
507: if (i != -1) {
508: listLF.lRemoveCommand(cmd, i);
509: }
510: } // synchronized
511: }
512:
513: /**
514: * Sets the <code>Command</code> to be used for an
515: * <code>IMPLICIT</code> <code>List</code> selection
516: * action.
517: * By default, an implicit selection of a List will result in the
518: * predefined <code>List.SELECT_COMMAND</code> being used. This
519: * behavior may be
520: * overridden by calling the <code>List.setSelectCommand()</code>
521: * method with an
522: * appropriate parameter value. If a <code>null</code> reference
523: * is passed, this
524: * indicates that no "select" action is appropriate for
525: * the contents
526: * of this <code>List</code>.
527: *
528: * <p> If a reference to a command object is passed, and
529: * it is not the special command <code>List.SELECT_COMMAND</code>, and
530: * it is not currently present on this <code>List</code> object,
531: * the command object is added to this <code>List</code> as if
532: * <code>addCommand(command)</code> had been called
533: * prior to the command being made the select command. This
534: * indicates that this command
535: * is to be invoked when the user performs the "select"
536: * on an element of
537: * this <code>List</code>. </p>
538: *
539: * <p> The select command should have a command type of
540: * <code>ITEM</code> to indicate
541: * that it operates on the currently selected object. It is not an error
542: * if the command is of some other type.
543: * (<code>List.SELECT_COMMAND</code> has a type
544: * of <code>SCREEN</code> for historical purposes.) For purposes
545: * of presentation and
546: * placement within its user interface, the implementation is allowed to
547: * treat the select command as if it were of type <code>ITEM</code>. </p>
548: *
549: * <p> If the select command is later removed from the <code>List</code>
550: * with <code>removeCommand()</code>, the <code>List</code> is set to have
551: * no select command as if <code>List.setSelectCommand(null)</code> had
552: * been called.</p>
553: *
554: * <p> The default behavior can be reestablished explicitly by calling
555: * <code>setSelectCommand()</code> with an argument of
556: * <code>List.SELECT_COMMAND</code>.</p>
557: *
558: * <p> This method has no effect if the type of the
559: * <code>List</code> is not <code>IMPLICIT</code>. </p>
560: *
561: * @param command the command to be used for an <code>IMPLICIT</code> list
562: * selection action, or <code>null</code> if there is none
563: *
564: */
565: public void setSelectCommand(Command command) {
566: // If we're not an IMPLICIT List, ignore this method
567: // call entirely
568: if (cg.choiceType != Choice.IMPLICIT) {
569: return;
570: }
571:
572: // Here we're just resetting the default behavior
573: // of this implicit List
574: if (command == List.SELECT_COMMAND) {
575: selectCommand = command;
576: return;
577: }
578:
579: // Here we're deciding there is no appropriate default
580: // command for a selection
581: if (command == null) {
582: selectCommand = null;
583: return;
584: }
585:
586: // SYNC NOTE: We grab the lock here because we need to determine
587: // if the command is in the Displayables command set AND we need
588: // to protect ourselves from the Command being removed from the
589: // set just after we've done the check. #See how we override the
590: // removeCommand() method in this class
591: synchronized (Display.LCDUILock) {
592: // We ensure that the provided Command has been added
593: // to this List.
594: addCommandImpl(command);
595:
596: selectCommand = command;
597: }
598: }
599:
600: /**
601: * Sets the application's preferred policy for fitting
602: * <code>Choice</code> element
603: * contents to the available screen space. The set policy applies for all
604: * elements of the <code>Choice</code> object. Valid values are
605: * {@link #TEXT_WRAP_DEFAULT}, {@link #TEXT_WRAP_ON},
606: * and {@link #TEXT_WRAP_OFF}. Fit policy is a hint, and the
607: * implementation may disregard the application's preferred policy.
608: *
609: * @param fitPolicy preferred content fit policy for choice elements
610: * @throws IllegalArgumentException if <code>fitPolicy</code> is invalid
611: * @see #getFitPolicy
612: */
613: public void setFitPolicy(int fitPolicy) {
614: cg.setFitPolicy(fitPolicy);
615: }
616:
617: /**
618: * Gets the application's preferred policy for fitting
619: * <code>Choice</code> element
620: * contents to the available screen space. The value returned is the
621: * policy that had been set by the application, even if that value had
622: * been disregarded by the implementation.
623: *
624: * @return one of {@link #TEXT_WRAP_DEFAULT}, {@link #TEXT_WRAP_ON}, or
625: * {@link #TEXT_WRAP_OFF}
626: * @see #setFitPolicy
627: */
628: public int getFitPolicy() {
629: return cg.getFitPolicy();
630: }
631:
632: /**
633: * Sets the application's preferred font for
634: * rendering the specified element of this <code>Choice</code>.
635: * An element's font is a hint, and the implementation may disregard
636: * the application's preferred font.
637: *
638: * <p> The <code>elementNum</code> parameter must be within the range
639: * <code>[0..size()-1]</code>, inclusive.</p>
640: *
641: * <p> The <code>font</code> parameter must be a valid <code>Font</code>
642: * object or <code>null</code>. If the <code>font</code> parameter is
643: * <code>null</code>, the implementation must use its default font
644: * to render the element.</p>
645: *
646: * @param elementNum the index of the element, starting from zero
647: * @param font the preferred font to use to render the element
648: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
649: * @see #getFont
650: */
651: public void setFont(int elementNum, Font font) {
652: cg.setFont(elementNum, font);
653: }
654:
655: /**
656: * Gets the application's preferred font for
657: * rendering the specified element of this <code>Choice</code>. The
658: * value returned is the font that had been set by the application,
659: * even if that value had been disregarded by the implementation.
660: * If no font had been set by the application, or if the application
661: * explicitly set the font to <code>null</code>, the value is the default
662: * font chosen by the implementation.
663: *
664: * <p> The <code>elementNum</code> parameter must be within the range
665: * <code>[0..size()-1]</code>, inclusive.</p>
666: *
667: * @param elementNum the index of the element, starting from zero
668: * @return the preferred font to use to render the element
669: * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid
670: * @see #setFont(int elementNum, Font font)
671: */
672: public Font getFont(int elementNum) {
673: return cg.getFont(elementNum);
674: }
675:
676: // package private members
677:
678: // SYNC NOTE: The List constructor establishes 'cg' as non-null
679: // and which remains constant for the lifetime of this object.
680: // All public api calls are delegated to the 'cg' object and
681: // therefore no synchronization is necessary.
682: /**
683: * An internal choicegroup to handle the selections
684: */
685: ChoiceGroup cg;
686:
687: /**
688: * This is an internal Command which represents the callback
689: * to a selection event of an IMPLICIT list. By default, this
690: * command is the predefined List.SELECT_COMMAND. This can be
691: * overridden however using the setSelectCommand().
692: */
693: Command selectCommand = SELECT_COMMAND;
694:
695: /**
696: * Look & Feel object associated with this List
697: */
698: FormLF listLF;
699: }
|