1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
265 synchronized (getTreeLock()) {
266 ListPeer peer = (ListPeer)this.peer;
267 if (peer != null) {
268 selected = peer.getSelectedIndexes();
269 }
270 super.removeNotify();
271 }
272 }
273
274 /**
275 * Gets the number of items in the list.
276 * @return the number of items in the list
277 * @see #getItem
278 * @since JDK1.1
279 */
280 public int getItemCount() {
281 return countItems();
282 }
283
284 /**
285 * @deprecated As of JDK version 1.1,
286 * replaced by <code>getItemCount()</code>.
287 */
288 @Deprecated
289 public int countItems() {
290 return items.size();
291 }
292
293 /**
294 * Gets the item associated with the specified index.
295 * @return an item that is associated with
296 * the specified index
297 * @param index the position of the item
298 * @see #getItemCount
299 */
300 public String getItem(int index) {
301 return getItemImpl(index);
302 }
303
304 // NOTE: This method may be called by privileged threads.
316 * @see #deselect
317 * @see #isIndexSelected
318 * @since JDK1.1
319 */
320 public synchronized String[] getItems() {
321 String itemCopies[] = new String[items.size()];
322 items.copyInto(itemCopies);
323 return itemCopies;
324 }
325
326 /**
327 * Adds the specified item to the end of scrolling list.
328 * @param item the item to be added
329 * @since JDK1.1
330 */
331 public void add(String item) {
332 addItem(item);
333 }
334
335 /**
336 * @deprecated replaced by <code>add(String)</code>.
337 */
338 @Deprecated
339 public void addItem(String item) {
340 addItem(item, -1);
341 }
342
343 /**
344 * Adds the specified item to the the scrolling list
345 * at the position indicated by the index. The index is
346 * zero-based. If the value of the index is less than zero,
347 * or if the value of the index is greater than or equal to
348 * the number of items in the list, then the item is added
349 * to the end of the list.
350 * @param item the item to be added;
351 * if this parameter is <code>null</code> then the item is
352 * treated as an empty string, <code>""</code>
353 * @param index the position at which to add the item
354 * @since JDK1.1
355 */
356 public void add(String item, int index) {
357 addItem(item, index);
358 }
359
360 /**
361 * @deprecated replaced by <code>add(String, int)</code>.
362 */
363 @Deprecated
364 public synchronized void addItem(String item, int index) {
365 if (index < -1 || index >= items.size()) {
366 index = -1;
367 }
368
369 if (item == null) {
370 item = "";
371 }
372
373 if (index == -1) {
374 items.addElement(item);
375 } else {
376 items.insertElementAt(item, index);
377 }
378
379 ListPeer peer = (ListPeer)this.peer;
380 if (peer != null) {
438 }
439 }
440
441 /**
442 * Removes the item at the specified position
443 * from this scrolling list.
444 * If the item with the specified position is selected, and is the
445 * only selected item in the list, the list is set to have no selection.
446 * @param position the index of the item to delete
447 * @see #add(String, int)
448 * @since JDK1.1
449 * @exception ArrayIndexOutOfBoundsException
450 * if the <code>position</code> is less than 0 or
451 * greater than <code>getItemCount()-1</code>
452 */
453 public void remove(int position) {
454 delItem(position);
455 }
456
457 /**
458 * @deprecated replaced by <code>remove(String)</code>
459 * and <code>remove(int)</code>.
460 */
461 @Deprecated
462 public void delItem(int position) {
463 delItems(position, position);
464 }
465
466 /**
467 * Gets the index of the selected item on the list,
468 *
469 * @return the index of the selected item;
470 * if no item is selected, or if multiple items are
471 * selected, <code>-1</code> is returned.
472 * @see #select
473 * @see #deselect
474 * @see #isIndexSelected
475 */
476 public synchronized int getSelectedIndex() {
477 int sel[] = getSelectedIndexes();
629 return;
630 }
631 }
632 }
633
634 /**
635 * Determines if the specified item in this scrolling list is
636 * selected.
637 * @param index the item to be checked
638 * @return <code>true</code> if the specified item has been
639 * selected; <code>false</code> otherwise
640 * @see #select
641 * @see #deselect
642 * @since JDK1.1
643 */
644 public boolean isIndexSelected(int index) {
645 return isSelected(index);
646 }
647
648 /**
649 * @deprecated As of JDK version 1.1,
650 * replaced by <code>isIndexSelected(int)</code>.
651 */
652 @Deprecated
653 public boolean isSelected(int index) {
654 int sel[] = getSelectedIndexes();
655 for (int i = 0 ; i < sel.length ; i++) {
656 if (sel[i] == index) {
657 return true;
658 }
659 }
660 return false;
661 }
662
663 /**
664 * Gets the number of visible lines in this list. Note that
665 * once the <code>List</code> has been created, this number
666 * will never change.
667 * @return the number of visible lines in this scrolling list
668 */
669 public int getRows() {
670 return rows;
671 }
672
673 /**
674 * Determines whether this list allows multiple selections.
675 * @return <code>true</code> if this list allows multiple
676 * selections; otherwise, <code>false</code>
677 * @see #setMultipleMode
678 * @since JDK1.1
679 */
680 public boolean isMultipleMode() {
681 return allowsMultipleSelections();
682 }
683
684 /**
685 * @deprecated As of JDK version 1.1,
686 * replaced by <code>isMultipleMode()</code>.
687 */
688 @Deprecated
689 public boolean allowsMultipleSelections() {
690 return multipleMode;
691 }
692
693 /**
694 * Sets the flag that determines whether this list
695 * allows multiple selections.
696 * When the selection mode is changed from multiple-selection to
697 * single-selection, the selected items change as follows:
698 * If a selected item has the location cursor, only that
699 * item will remain selected. If no selected item has the
700 * location cursor, all items will be deselected.
701 * @param b if <code>true</code> then multiple selections
702 * are allowed; otherwise, only one item from
703 * the list can be selected at once
704 * @see #isMultipleMode
705 * @since JDK1.1
706 */
707 public void setMultipleMode(boolean b) {
708 setMultipleSelections(b);
709 }
710
711 /**
712 * @deprecated As of JDK version 1.1,
713 * replaced by <code>setMultipleMode(boolean)</code>.
714 */
715 @Deprecated
716 public synchronized void setMultipleSelections(boolean b) {
717 if (b != multipleMode) {
718 multipleMode = b;
719 ListPeer peer = (ListPeer)this.peer;
720 if (peer != null) {
721 peer.setMultipleMode(b);
722 }
723 }
724 }
725
726 /**
727 * Gets the index of the item that was last made visible by
728 * the method <code>makeVisible</code>.
729 * @return the index of the item that was last made visible
730 * @see #makeVisible
731 */
743 ListPeer peer = (ListPeer)this.peer;
744 if (peer != null) {
745 peer.makeVisible(index);
746 }
747 }
748
749 /**
750 * Gets the preferred dimensions for a list with the specified
751 * number of rows.
752 * @param rows number of rows in the list
753 * @return the preferred dimensions for displaying this scrolling list
754 * given that the specified number of rows must be visible
755 * @see java.awt.Component#getPreferredSize
756 * @since JDK1.1
757 */
758 public Dimension getPreferredSize(int rows) {
759 return preferredSize(rows);
760 }
761
762 /**
763 * @deprecated As of JDK version 1.1,
764 * replaced by <code>getPreferredSize(int)</code>.
765 */
766 @Deprecated
767 public Dimension preferredSize(int rows) {
768 synchronized (getTreeLock()) {
769 ListPeer peer = (ListPeer)this.peer;
770 return (peer != null) ?
771 peer.getPreferredSize(rows) :
772 super.preferredSize();
773 }
774 }
775
776 /**
777 * Gets the preferred size of this scrolling list.
778 * @return the preferred dimensions for displaying this scrolling list
779 * @see java.awt.Component#getPreferredSize
780 * @since JDK1.1
781 */
782 public Dimension getPreferredSize() {
793 return (rows > 0) ?
794 preferredSize(rows) :
795 super.preferredSize();
796 }
797 }
798
799 /**
800 * Gets the minimum dimensions for a list with the specified
801 * number of rows.
802 * @param rows number of rows in the list
803 * @return the minimum dimensions for displaying this scrolling list
804 * given that the specified number of rows must be visible
805 * @see java.awt.Component#getMinimumSize
806 * @since JDK1.1
807 */
808 public Dimension getMinimumSize(int rows) {
809 return minimumSize(rows);
810 }
811
812 /**
813 * @deprecated As of JDK version 1.1,
814 * replaced by <code>getMinimumSize(int)</code>.
815 */
816 @Deprecated
817 public Dimension minimumSize(int rows) {
818 synchronized (getTreeLock()) {
819 ListPeer peer = (ListPeer)this.peer;
820 return (peer != null) ?
821 peer.getMinimumSize(rows) :
822 super.minimumSize();
823 }
824 }
825
826 /**
827 * Determines the minimum size of this scrolling list.
828 * @return the minimum dimensions needed
829 * to display this scrolling list
830 * @see java.awt.Component#getMinimumSize()
831 * @since JDK1.1
832 */
1129 * @see java.awt.Component#enableEvents
1130 * @since JDK1.1
1131 */
1132 protected void processActionEvent(ActionEvent e) {
1133 ActionListener listener = actionListener;
1134 if (listener != null) {
1135 listener.actionPerformed(e);
1136 }
1137 }
1138
1139 /**
1140 * Returns the parameter string representing the state of this
1141 * scrolling list. This string is useful for debugging.
1142 * @return the parameter string of this scrolling list
1143 */
1144 protected String paramString() {
1145 return super.paramString() + ",selected=" + getSelectedItem();
1146 }
1147
1148 /**
1149 * @deprecated As of JDK version 1.1,
1150 * Not for public use in the future.
1151 * This method is expected to be retained only as a package
1152 * private method.
1153 */
1154 @Deprecated
1155 public synchronized void delItems(int start, int end) {
1156 for (int i = end; i >= start; i--) {
1157 items.removeElementAt(i);
1158 }
1159 ListPeer peer = (ListPeer)this.peer;
1160 if (peer != null) {
1161 peer.delItems(start, end);
1162 }
1163 }
1164
1165 /*
1166 * Serialization support. Since the value of the selected
1167 * field isn't necessarily up to date, we sync it up with the
1168 * peer before serializing.
1273 if (accessibleContext == null) {
1274 accessibleContext = new AccessibleAWTList();
1275 }
1276 return accessibleContext;
1277 }
1278
1279 /**
1280 * This class implements accessibility support for the
1281 * <code>List</code> class. It provides an implementation of the
1282 * Java Accessibility API appropriate to list user-interface elements.
1283 * @since 1.3
1284 */
1285 protected class AccessibleAWTList extends AccessibleAWTComponent
1286 implements AccessibleSelection, ItemListener, ActionListener
1287 {
1288 /*
1289 * JDK 1.3 serialVersionUID
1290 */
1291 private static final long serialVersionUID = 7924617370136012829L;
1292
1293 public AccessibleAWTList() {
1294 super();
1295 List.this.addActionListener(this);
1296 List.this.addItemListener(this);
1297 }
1298
1299 public void actionPerformed(ActionEvent event) {
1300 }
1301
1302 public void itemStateChanged(ItemEvent event) {
1303 }
1304
1305 /**
1306 * Get the state set of this object.
1307 *
1308 * @return an instance of AccessibleState containing the current state
1309 * of the object
1310 * @see AccessibleState
1311 */
1312 public AccessibleStateSet getAccessibleStateSet() {
1474 /**
1475 * This class implements accessibility support for
1476 * List children. It provides an implementation of the
1477 * Java Accessibility API appropriate to list children
1478 * user-interface elements.
1479 * @since 1.3
1480 */
1481 protected class AccessibleAWTListChild extends AccessibleAWTComponent
1482 implements Accessible
1483 {
1484 /*
1485 * JDK 1.3 serialVersionUID
1486 */
1487 private static final long serialVersionUID = 4412022926028300317L;
1488
1489 // [[[FIXME]]] need to finish implementing this!!!
1490
1491 private List parent;
1492 private int indexInParent;
1493
1494 public AccessibleAWTListChild(List parent, int indexInParent) {
1495 this.parent = parent;
1496 this.setAccessibleParent(parent);
1497 this.indexInParent = indexInParent;
1498 }
1499
1500 //
1501 // required Accessible methods
1502 //
1503 /**
1504 * Gets the AccessibleContext for this object. In the
1505 * implementation of the Java Accessibility API for this class,
1506 * return this object, which acts as its own AccessibleContext.
1507 *
1508 * @return this object
1509 */
1510 public AccessibleContext getAccessibleContext() {
1511 return this;
1512 }
1513
|
1 /*
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
265 synchronized (getTreeLock()) {
266 ListPeer peer = (ListPeer)this.peer;
267 if (peer != null) {
268 selected = peer.getSelectedIndexes();
269 }
270 super.removeNotify();
271 }
272 }
273
274 /**
275 * Gets the number of items in the list.
276 * @return the number of items in the list
277 * @see #getItem
278 * @since JDK1.1
279 */
280 public int getItemCount() {
281 return countItems();
282 }
283
284 /**
285 * @return the number of items in the list
286 * @deprecated As of JDK version 1.1,
287 * replaced by <code>getItemCount()</code>.
288 */
289 @Deprecated
290 public int countItems() {
291 return items.size();
292 }
293
294 /**
295 * Gets the item associated with the specified index.
296 * @return an item that is associated with
297 * the specified index
298 * @param index the position of the item
299 * @see #getItemCount
300 */
301 public String getItem(int index) {
302 return getItemImpl(index);
303 }
304
305 // NOTE: This method may be called by privileged threads.
317 * @see #deselect
318 * @see #isIndexSelected
319 * @since JDK1.1
320 */
321 public synchronized String[] getItems() {
322 String itemCopies[] = new String[items.size()];
323 items.copyInto(itemCopies);
324 return itemCopies;
325 }
326
327 /**
328 * Adds the specified item to the end of scrolling list.
329 * @param item the item to be added
330 * @since JDK1.1
331 */
332 public void add(String item) {
333 addItem(item);
334 }
335
336 /**
337 * Adds the specified item to the end of the list
338 * @param item the item to be added
339 * @deprecated replaced by <code>add(String)</code>.
340 */
341 @Deprecated
342 public void addItem(String item) {
343 addItem(item, -1);
344 }
345
346 /**
347 * Adds the specified item to the the scrolling list
348 * at the position indicated by the index. The index is
349 * zero-based. If the value of the index is less than zero,
350 * or if the value of the index is greater than or equal to
351 * the number of items in the list, then the item is added
352 * to the end of the list.
353 * @param item the item to be added;
354 * if this parameter is <code>null</code> then the item is
355 * treated as an empty string, <code>""</code>
356 * @param index the position at which to add the item
357 * @since JDK1.1
358 */
359 public void add(String item, int index) {
360 addItem(item, index);
361 }
362
363 /**
364 * Adds the specified item to the the list
365 * at the position indicated by the index.
366 * @param item the item to be added
367 * @param index the position at which to add the item
368 * @deprecated replaced by <code>add(String, int)</code>.
369 */
370 @Deprecated
371 public synchronized void addItem(String item, int index) {
372 if (index < -1 || index >= items.size()) {
373 index = -1;
374 }
375
376 if (item == null) {
377 item = "";
378 }
379
380 if (index == -1) {
381 items.addElement(item);
382 } else {
383 items.insertElementAt(item, index);
384 }
385
386 ListPeer peer = (ListPeer)this.peer;
387 if (peer != null) {
445 }
446 }
447
448 /**
449 * Removes the item at the specified position
450 * from this scrolling list.
451 * If the item with the specified position is selected, and is the
452 * only selected item in the list, the list is set to have no selection.
453 * @param position the index of the item to delete
454 * @see #add(String, int)
455 * @since JDK1.1
456 * @exception ArrayIndexOutOfBoundsException
457 * if the <code>position</code> is less than 0 or
458 * greater than <code>getItemCount()-1</code>
459 */
460 public void remove(int position) {
461 delItem(position);
462 }
463
464 /**
465 * Removes the item at the specified position
466 * @param position the index of the item to delete
467 * @deprecated replaced by <code>remove(String)</code>
468 * and <code>remove(int)</code>.
469 */
470 @Deprecated
471 public void delItem(int position) {
472 delItems(position, position);
473 }
474
475 /**
476 * Gets the index of the selected item on the list,
477 *
478 * @return the index of the selected item;
479 * if no item is selected, or if multiple items are
480 * selected, <code>-1</code> is returned.
481 * @see #select
482 * @see #deselect
483 * @see #isIndexSelected
484 */
485 public synchronized int getSelectedIndex() {
486 int sel[] = getSelectedIndexes();
638 return;
639 }
640 }
641 }
642
643 /**
644 * Determines if the specified item in this scrolling list is
645 * selected.
646 * @param index the item to be checked
647 * @return <code>true</code> if the specified item has been
648 * selected; <code>false</code> otherwise
649 * @see #select
650 * @see #deselect
651 * @since JDK1.1
652 */
653 public boolean isIndexSelected(int index) {
654 return isSelected(index);
655 }
656
657 /**
658 * Determines if the specified item in the list is selected.
659 * @param index specifies the item to be checked
660 * @return {@code true} if the item is selected; otherwise {@code false}
661 * @deprecated As of JDK version 1.1,
662 * replaced by <code>isIndexSelected(int)</code>.
663 */
664 @Deprecated
665 public boolean isSelected(int index) {
666 int sel[] = getSelectedIndexes();
667 for (int i = 0 ; i < sel.length ; i++) {
668 if (sel[i] == index) {
669 return true;
670 }
671 }
672 return false;
673 }
674
675 /**
676 * Gets the number of visible lines in this list. Note that
677 * once the <code>List</code> has been created, this number
678 * will never change.
679 * @return the number of visible lines in this scrolling list
680 */
681 public int getRows() {
682 return rows;
683 }
684
685 /**
686 * Determines whether this list allows multiple selections.
687 * @return <code>true</code> if this list allows multiple
688 * selections; otherwise, <code>false</code>
689 * @see #setMultipleMode
690 * @since JDK1.1
691 */
692 public boolean isMultipleMode() {
693 return allowsMultipleSelections();
694 }
695
696 /**
697 * Determines whether this list allows multiple selections.
698 * @return {@code true} if this list allows multiple
699 * selections; otherwise {@code false}
700 * @deprecated As of JDK version 1.1,
701 * replaced by <code>isMultipleMode()</code>.
702 */
703 @Deprecated
704 public boolean allowsMultipleSelections() {
705 return multipleMode;
706 }
707
708 /**
709 * Sets the flag that determines whether this list
710 * allows multiple selections.
711 * When the selection mode is changed from multiple-selection to
712 * single-selection, the selected items change as follows:
713 * If a selected item has the location cursor, only that
714 * item will remain selected. If no selected item has the
715 * location cursor, all items will be deselected.
716 * @param b if <code>true</code> then multiple selections
717 * are allowed; otherwise, only one item from
718 * the list can be selected at once
719 * @see #isMultipleMode
720 * @since JDK1.1
721 */
722 public void setMultipleMode(boolean b) {
723 setMultipleSelections(b);
724 }
725
726 /**
727 * Enables or disables multiple selection mode for this list.
728 * @param b {@code true} to enable multiple mode, {@code false} otherwise
729 * @deprecated As of JDK version 1.1,
730 * replaced by <code>setMultipleMode(boolean)</code>.
731 */
732 @Deprecated
733 public synchronized void setMultipleSelections(boolean b) {
734 if (b != multipleMode) {
735 multipleMode = b;
736 ListPeer peer = (ListPeer)this.peer;
737 if (peer != null) {
738 peer.setMultipleMode(b);
739 }
740 }
741 }
742
743 /**
744 * Gets the index of the item that was last made visible by
745 * the method <code>makeVisible</code>.
746 * @return the index of the item that was last made visible
747 * @see #makeVisible
748 */
760 ListPeer peer = (ListPeer)this.peer;
761 if (peer != null) {
762 peer.makeVisible(index);
763 }
764 }
765
766 /**
767 * Gets the preferred dimensions for a list with the specified
768 * number of rows.
769 * @param rows number of rows in the list
770 * @return the preferred dimensions for displaying this scrolling list
771 * given that the specified number of rows must be visible
772 * @see java.awt.Component#getPreferredSize
773 * @since JDK1.1
774 */
775 public Dimension getPreferredSize(int rows) {
776 return preferredSize(rows);
777 }
778
779 /**
780 * Returns the preferred size of this component
781 * assuming it has the specified number of rows.
782 * @param rows the number of rows
783 * @return the preferred dimensions for displaying this list
784 * @deprecated As of JDK version 1.1,
785 * replaced by <code>getPreferredSize(int)</code>.
786 */
787 @Deprecated
788 public Dimension preferredSize(int rows) {
789 synchronized (getTreeLock()) {
790 ListPeer peer = (ListPeer)this.peer;
791 return (peer != null) ?
792 peer.getPreferredSize(rows) :
793 super.preferredSize();
794 }
795 }
796
797 /**
798 * Gets the preferred size of this scrolling list.
799 * @return the preferred dimensions for displaying this scrolling list
800 * @see java.awt.Component#getPreferredSize
801 * @since JDK1.1
802 */
803 public Dimension getPreferredSize() {
814 return (rows > 0) ?
815 preferredSize(rows) :
816 super.preferredSize();
817 }
818 }
819
820 /**
821 * Gets the minimum dimensions for a list with the specified
822 * number of rows.
823 * @param rows number of rows in the list
824 * @return the minimum dimensions for displaying this scrolling list
825 * given that the specified number of rows must be visible
826 * @see java.awt.Component#getMinimumSize
827 * @since JDK1.1
828 */
829 public Dimension getMinimumSize(int rows) {
830 return minimumSize(rows);
831 }
832
833 /**
834 * Returns the minimum dimensions for the list
835 * with the specified number of rows.
836 * @param rows the number of rows in the list
837 * @return the minimum dimensions for displaying this list
838 * @deprecated As of JDK version 1.1,
839 * replaced by <code>getMinimumSize(int)</code>.
840 */
841 @Deprecated
842 public Dimension minimumSize(int rows) {
843 synchronized (getTreeLock()) {
844 ListPeer peer = (ListPeer)this.peer;
845 return (peer != null) ?
846 peer.getMinimumSize(rows) :
847 super.minimumSize();
848 }
849 }
850
851 /**
852 * Determines the minimum size of this scrolling list.
853 * @return the minimum dimensions needed
854 * to display this scrolling list
855 * @see java.awt.Component#getMinimumSize()
856 * @since JDK1.1
857 */
1154 * @see java.awt.Component#enableEvents
1155 * @since JDK1.1
1156 */
1157 protected void processActionEvent(ActionEvent e) {
1158 ActionListener listener = actionListener;
1159 if (listener != null) {
1160 listener.actionPerformed(e);
1161 }
1162 }
1163
1164 /**
1165 * Returns the parameter string representing the state of this
1166 * scrolling list. This string is useful for debugging.
1167 * @return the parameter string of this scrolling list
1168 */
1169 protected String paramString() {
1170 return super.paramString() + ",selected=" + getSelectedItem();
1171 }
1172
1173 /**
1174 * Deletes the list items in the specified index range.
1175 * @param start the beginning index of the range to delete
1176 * @param end the ending index of the range to delete
1177 * @deprecated As of JDK version 1.1,
1178 * Not for public use in the future.
1179 * This method is expected to be retained only as a package
1180 * private method.
1181 */
1182 @Deprecated
1183 public synchronized void delItems(int start, int end) {
1184 for (int i = end; i >= start; i--) {
1185 items.removeElementAt(i);
1186 }
1187 ListPeer peer = (ListPeer)this.peer;
1188 if (peer != null) {
1189 peer.delItems(start, end);
1190 }
1191 }
1192
1193 /*
1194 * Serialization support. Since the value of the selected
1195 * field isn't necessarily up to date, we sync it up with the
1196 * peer before serializing.
1301 if (accessibleContext == null) {
1302 accessibleContext = new AccessibleAWTList();
1303 }
1304 return accessibleContext;
1305 }
1306
1307 /**
1308 * This class implements accessibility support for the
1309 * <code>List</code> class. It provides an implementation of the
1310 * Java Accessibility API appropriate to list user-interface elements.
1311 * @since 1.3
1312 */
1313 protected class AccessibleAWTList extends AccessibleAWTComponent
1314 implements AccessibleSelection, ItemListener, ActionListener
1315 {
1316 /*
1317 * JDK 1.3 serialVersionUID
1318 */
1319 private static final long serialVersionUID = 7924617370136012829L;
1320
1321 /**
1322 * Constructs new {@code AccessibleAWTList}
1323 */
1324 public AccessibleAWTList() {
1325 super();
1326 List.this.addActionListener(this);
1327 List.this.addItemListener(this);
1328 }
1329
1330 public void actionPerformed(ActionEvent event) {
1331 }
1332
1333 public void itemStateChanged(ItemEvent event) {
1334 }
1335
1336 /**
1337 * Get the state set of this object.
1338 *
1339 * @return an instance of AccessibleState containing the current state
1340 * of the object
1341 * @see AccessibleState
1342 */
1343 public AccessibleStateSet getAccessibleStateSet() {
1505 /**
1506 * This class implements accessibility support for
1507 * List children. It provides an implementation of the
1508 * Java Accessibility API appropriate to list children
1509 * user-interface elements.
1510 * @since 1.3
1511 */
1512 protected class AccessibleAWTListChild extends AccessibleAWTComponent
1513 implements Accessible
1514 {
1515 /*
1516 * JDK 1.3 serialVersionUID
1517 */
1518 private static final long serialVersionUID = 4412022926028300317L;
1519
1520 // [[[FIXME]]] need to finish implementing this!!!
1521
1522 private List parent;
1523 private int indexInParent;
1524
1525 /**
1526 * Constructs new {@code AccessibleAWTListChild} with the given
1527 * parent {@code List} and 0-based index of this object in the parent.
1528 * @param parent the parent {@code List}
1529 * @param indexInParent the index in the parent
1530 */
1531 public AccessibleAWTListChild(List parent, int indexInParent) {
1532 this.parent = parent;
1533 this.setAccessibleParent(parent);
1534 this.indexInParent = indexInParent;
1535 }
1536
1537 //
1538 // required Accessible methods
1539 //
1540 /**
1541 * Gets the AccessibleContext for this object. In the
1542 * implementation of the Java Accessibility API for this class,
1543 * return this object, which acts as its own AccessibleContext.
1544 *
1545 * @return this object
1546 */
1547 public AccessibleContext getAccessibleContext() {
1548 return this;
1549 }
1550
|