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 * Returns the number of items in the list.
286 *
287 * @return the number of items in the list
288 * @deprecated As of JDK version 1.1,
289 * replaced by <code>getItemCount()</code>.
290 */
291 @Deprecated
292 public int countItems() {
293 return items.size();
294 }
295
296 /**
297 * Gets the item associated with the specified index.
298 * @return an item that is associated with
299 * the specified index
300 * @param index the position of the item
301 * @see #getItemCount
302 */
303 public String getItem(int index) {
304 return getItemImpl(index);
305 }
306
307 // NOTE: This method may be called by privileged threads.
319 * @see #deselect
320 * @see #isIndexSelected
321 * @since JDK1.1
322 */
323 public synchronized String[] getItems() {
324 String itemCopies[] = new String[items.size()];
325 items.copyInto(itemCopies);
326 return itemCopies;
327 }
328
329 /**
330 * Adds the specified item to the end of scrolling list.
331 * @param item the item to be added
332 * @since JDK1.1
333 */
334 public void add(String item) {
335 addItem(item);
336 }
337
338 /**
339 * Adds the specified item to the end of the list.
340 *
341 * @param item the item to be added
342 * @deprecated replaced by <code>add(String)</code>.
343 */
344 @Deprecated
345 public void addItem(String item) {
346 addItem(item, -1);
347 }
348
349 /**
350 * Adds the specified item to the the scrolling list
351 * at the position indicated by the index. The index is
352 * zero-based. If the value of the index is less than zero,
353 * or if the value of the index is greater than or equal to
354 * the number of items in the list, then the item is added
355 * to the end of the list.
356 * @param item the item to be added;
357 * if this parameter is <code>null</code> then the item is
358 * treated as an empty string, <code>""</code>
359 * @param index the position at which to add the item
360 * @since JDK1.1
361 */
362 public void add(String item, int index) {
363 addItem(item, index);
364 }
365
366 /**
367 * Adds the specified item to the the list
368 * at the position indicated by the index.
369 *
370 * @param item the item to be added
371 * @param index the position at which to add the item
372 * @deprecated replaced by <code>add(String, int)</code>.
373 */
374 @Deprecated
375 public synchronized void addItem(String item, int index) {
376 if (index < -1 || index >= items.size()) {
377 index = -1;
378 }
379
380 if (item == null) {
381 item = "";
382 }
383
384 if (index == -1) {
385 items.addElement(item);
386 } else {
387 items.insertElementAt(item, index);
388 }
389
390 ListPeer peer = (ListPeer)this.peer;
391 if (peer != null) {
449 }
450 }
451
452 /**
453 * Removes the item at the specified position
454 * from this scrolling list.
455 * If the item with the specified position is selected, and is the
456 * only selected item in the list, the list is set to have no selection.
457 * @param position the index of the item to delete
458 * @see #add(String, int)
459 * @since JDK1.1
460 * @exception ArrayIndexOutOfBoundsException
461 * if the <code>position</code> is less than 0 or
462 * greater than <code>getItemCount()-1</code>
463 */
464 public void remove(int position) {
465 delItem(position);
466 }
467
468 /**
469 * Removes the item at the specified position.
470 *
471 * @param position the index of the item to delete
472 * @deprecated replaced by <code>remove(String)</code>
473 * and <code>remove(int)</code>.
474 */
475 @Deprecated
476 public void delItem(int position) {
477 delItems(position, position);
478 }
479
480 /**
481 * Gets the index of the selected item on the list,
482 *
483 * @return the index of the selected item;
484 * if no item is selected, or if multiple items are
485 * selected, <code>-1</code> is returned.
486 * @see #select
487 * @see #deselect
488 * @see #isIndexSelected
489 */
490 public synchronized int getSelectedIndex() {
491 int sel[] = getSelectedIndexes();
643 return;
644 }
645 }
646 }
647
648 /**
649 * Determines if the specified item in this scrolling list is
650 * selected.
651 * @param index the item to be checked
652 * @return <code>true</code> if the specified item has been
653 * selected; <code>false</code> otherwise
654 * @see #select
655 * @see #deselect
656 * @since JDK1.1
657 */
658 public boolean isIndexSelected(int index) {
659 return isSelected(index);
660 }
661
662 /**
663 * Determines if the specified item in the list is selected.
664 *
665 * @param index specifies the item to be checked
666 * @return {@code true} if the item is selected; otherwise {@code false}
667 * @deprecated As of JDK version 1.1,
668 * replaced by <code>isIndexSelected(int)</code>.
669 */
670 @Deprecated
671 public boolean isSelected(int index) {
672 int sel[] = getSelectedIndexes();
673 for (int i = 0 ; i < sel.length ; i++) {
674 if (sel[i] == index) {
675 return true;
676 }
677 }
678 return false;
679 }
680
681 /**
682 * Gets the number of visible lines in this list. Note that
683 * once the <code>List</code> has been created, this number
684 * will never change.
685 * @return the number of visible lines in this scrolling list
686 */
687 public int getRows() {
688 return rows;
689 }
690
691 /**
692 * Determines whether this list allows multiple selections.
693 *
694 * @return <code>true</code> if this list allows multiple
695 * selections; otherwise, <code>false</code>
696 * @see #setMultipleMode
697 * @since JDK1.1
698 */
699 public boolean isMultipleMode() {
700 return allowsMultipleSelections();
701 }
702
703 /**
704 * Determines whether this list allows multiple selections.
705 *
706 * @return {@code true} if this list allows multiple
707 * selections; otherwise {@code false}
708 * @deprecated As of JDK version 1.1,
709 * replaced by <code>isMultipleMode()</code>.
710 */
711 @Deprecated
712 public boolean allowsMultipleSelections() {
713 return multipleMode;
714 }
715
716 /**
717 * Sets the flag that determines whether this list
718 * allows multiple selections.
719 * When the selection mode is changed from multiple-selection to
720 * single-selection, the selected items change as follows:
721 * If a selected item has the location cursor, only that
722 * item will remain selected. If no selected item has the
723 * location cursor, all items will be deselected.
724 * @param b if <code>true</code> then multiple selections
725 * are allowed; otherwise, only one item from
726 * the list can be selected at once
727 * @see #isMultipleMode
728 * @since JDK1.1
729 */
730 public void setMultipleMode(boolean b) {
731 setMultipleSelections(b);
732 }
733
734 /**
735 * Enables or disables multiple selection mode for this list.
736 *
737 * @param b {@code true} to enable multiple mode, {@code false} otherwise
738 * @deprecated As of JDK version 1.1,
739 * replaced by <code>setMultipleMode(boolean)</code>.
740 */
741 @Deprecated
742 public synchronized void setMultipleSelections(boolean b) {
743 if (b != multipleMode) {
744 multipleMode = b;
745 ListPeer peer = (ListPeer)this.peer;
746 if (peer != null) {
747 peer.setMultipleMode(b);
748 }
749 }
750 }
751
752 /**
753 * Gets the index of the item that was last made visible by
754 * the method <code>makeVisible</code>.
755 * @return the index of the item that was last made visible
756 * @see #makeVisible
757 */
769 ListPeer peer = (ListPeer)this.peer;
770 if (peer != null) {
771 peer.makeVisible(index);
772 }
773 }
774
775 /**
776 * Gets the preferred dimensions for a list with the specified
777 * number of rows.
778 * @param rows number of rows in the list
779 * @return the preferred dimensions for displaying this scrolling list
780 * given that the specified number of rows must be visible
781 * @see java.awt.Component#getPreferredSize
782 * @since JDK1.1
783 */
784 public Dimension getPreferredSize(int rows) {
785 return preferredSize(rows);
786 }
787
788 /**
789 * Returns the preferred size of this component
790 * assuming it has the specified number of rows.
791 *
792 * @param rows the number of rows
793 * @return the preferred dimensions for displaying this list
794 * @deprecated As of JDK version 1.1,
795 * replaced by <code>getPreferredSize(int)</code>.
796 */
797 @Deprecated
798 public Dimension preferredSize(int rows) {
799 synchronized (getTreeLock()) {
800 ListPeer peer = (ListPeer)this.peer;
801 return (peer != null) ?
802 peer.getPreferredSize(rows) :
803 super.preferredSize();
804 }
805 }
806
807 /**
808 * Gets the preferred size of this scrolling list.
809 * @return the preferred dimensions for displaying this scrolling list
810 * @see java.awt.Component#getPreferredSize
811 * @since JDK1.1
812 */
813 public Dimension getPreferredSize() {
824 return (rows > 0) ?
825 preferredSize(rows) :
826 super.preferredSize();
827 }
828 }
829
830 /**
831 * Gets the minimum dimensions for a list with the specified
832 * number of rows.
833 * @param rows number of rows in the list
834 * @return the minimum dimensions for displaying this scrolling list
835 * given that the specified number of rows must be visible
836 * @see java.awt.Component#getMinimumSize
837 * @since JDK1.1
838 */
839 public Dimension getMinimumSize(int rows) {
840 return minimumSize(rows);
841 }
842
843 /**
844 * Returns the minimum dimensions for the list
845 * with the specified number of rows.
846 *
847 * @param rows the number of rows in the list
848 * @return the minimum dimensions for displaying this list
849 * @deprecated As of JDK version 1.1,
850 * replaced by <code>getMinimumSize(int)</code>.
851 */
852 @Deprecated
853 public Dimension minimumSize(int rows) {
854 synchronized (getTreeLock()) {
855 ListPeer peer = (ListPeer)this.peer;
856 return (peer != null) ?
857 peer.getMinimumSize(rows) :
858 super.minimumSize();
859 }
860 }
861
862 /**
863 * Determines the minimum size of this scrolling list.
864 * @return the minimum dimensions needed
865 * to display this scrolling list
866 * @see java.awt.Component#getMinimumSize()
867 * @since JDK1.1
868 */
1165 * @see java.awt.Component#enableEvents
1166 * @since JDK1.1
1167 */
1168 protected void processActionEvent(ActionEvent e) {
1169 ActionListener listener = actionListener;
1170 if (listener != null) {
1171 listener.actionPerformed(e);
1172 }
1173 }
1174
1175 /**
1176 * Returns the parameter string representing the state of this
1177 * scrolling list. This string is useful for debugging.
1178 * @return the parameter string of this scrolling list
1179 */
1180 protected String paramString() {
1181 return super.paramString() + ",selected=" + getSelectedItem();
1182 }
1183
1184 /**
1185 * Deletes the list items in the specified index range.
1186 *
1187 * @param start the beginning index of the range to delete
1188 * @param end the ending index of the range to delete
1189 * @deprecated As of JDK version 1.1,
1190 * Not for public use in the future.
1191 * This method is expected to be retained only as a package
1192 * private method.
1193 */
1194 @Deprecated
1195 public synchronized void delItems(int start, int end) {
1196 for (int i = end; i >= start; i--) {
1197 items.removeElementAt(i);
1198 }
1199 ListPeer peer = (ListPeer)this.peer;
1200 if (peer != null) {
1201 peer.delItems(start, end);
1202 }
1203 }
1204
1205 /*
1206 * Serialization support. Since the value of the selected
1207 * field isn't necessarily up to date, we sync it up with the
1208 * peer before serializing.
1313 if (accessibleContext == null) {
1314 accessibleContext = new AccessibleAWTList();
1315 }
1316 return accessibleContext;
1317 }
1318
1319 /**
1320 * This class implements accessibility support for the
1321 * <code>List</code> class. It provides an implementation of the
1322 * Java Accessibility API appropriate to list user-interface elements.
1323 * @since 1.3
1324 */
1325 protected class AccessibleAWTList extends AccessibleAWTComponent
1326 implements AccessibleSelection, ItemListener, ActionListener
1327 {
1328 /*
1329 * JDK 1.3 serialVersionUID
1330 */
1331 private static final long serialVersionUID = 7924617370136012829L;
1332
1333 /**
1334 * Constructs new {@code AccessibleAWTList}
1335 */
1336 public AccessibleAWTList() {
1337 super();
1338 List.this.addActionListener(this);
1339 List.this.addItemListener(this);
1340 }
1341
1342 public void actionPerformed(ActionEvent event) {
1343 }
1344
1345 public void itemStateChanged(ItemEvent event) {
1346 }
1347
1348 /**
1349 * Get the state set of this object.
1350 *
1351 * @return an instance of AccessibleState containing the current state
1352 * of the object
1353 * @see AccessibleState
1354 */
1355 public AccessibleStateSet getAccessibleStateSet() {
1517 /**
1518 * This class implements accessibility support for
1519 * List children. It provides an implementation of the
1520 * Java Accessibility API appropriate to list children
1521 * user-interface elements.
1522 * @since 1.3
1523 */
1524 protected class AccessibleAWTListChild extends AccessibleAWTComponent
1525 implements Accessible
1526 {
1527 /*
1528 * JDK 1.3 serialVersionUID
1529 */
1530 private static final long serialVersionUID = 4412022926028300317L;
1531
1532 // [[[FIXME]]] need to finish implementing this!!!
1533
1534 private List parent;
1535 private int indexInParent;
1536
1537 /**
1538 * Constructs new {@code AccessibleAWTListChild} with the given
1539 * parent {@code List} and 0-based index of this object in the parent.
1540 *
1541 * @param parent the parent {@code List}
1542 * @param indexInParent the index in the parent
1543 */
1544 public AccessibleAWTListChild(List parent, int indexInParent) {
1545 this.parent = parent;
1546 this.setAccessibleParent(parent);
1547 this.indexInParent = indexInParent;
1548 }
1549
1550 //
1551 // required Accessible methods
1552 //
1553 /**
1554 * Gets the AccessibleContext for this object. In the
1555 * implementation of the Java Accessibility API for this class,
1556 * return this object, which acts as its own AccessibleContext.
1557 *
1558 * @return this object
1559 */
1560 public AccessibleContext getAccessibleContext() {
1561 return this;
1562 }
1563
|