equal
deleted
inserted
replaced
3056 * location, if it exists |
3056 * location, if it exists |
3057 */ |
3057 */ |
3058 public Accessible getAccessibleAt(Point p) { |
3058 public Accessible getAccessibleAt(Point p) { |
3059 int i = locationToIndex(p); |
3059 int i = locationToIndex(p); |
3060 if (i >= 0) { |
3060 if (i >= 0) { |
3061 return new AccessibleJListChild(JList.this, i); |
3061 return new ActionableAccessibleJListChild(JList.this, i); |
3062 } else { |
3062 } else { |
3063 return null; |
3063 return null; |
3064 } |
3064 } |
3065 } |
3065 } |
3066 |
3066 |
3083 */ |
3083 */ |
3084 public Accessible getAccessibleChild(int i) { |
3084 public Accessible getAccessibleChild(int i) { |
3085 if (i >= getModel().getSize()) { |
3085 if (i >= getModel().getSize()) { |
3086 return null; |
3086 return null; |
3087 } else { |
3087 } else { |
3088 return new AccessibleJListChild(JList.this, i); |
3088 return new ActionableAccessibleJListChild(JList.this, i); |
3089 } |
3089 } |
3090 } |
3090 } |
3091 |
3091 |
3092 /** |
3092 /** |
3093 * Get the AccessibleSelection associated with this object. In the |
3093 * Get the AccessibleSelection associated with this object. In the |
3188 * for list children. |
3188 * for list children. |
3189 */ |
3189 */ |
3190 protected class AccessibleJListChild extends AccessibleContext |
3190 protected class AccessibleJListChild extends AccessibleContext |
3191 implements Accessible, AccessibleComponent { |
3191 implements Accessible, AccessibleComponent { |
3192 private JList<E> parent = null; |
3192 private JList<E> parent = null; |
3193 private int indexInParent; |
3193 int indexInParent; |
3194 private Component component = null; |
3194 private Component component = null; |
3195 private AccessibleContext accessibleContext = null; |
3195 private AccessibleContext accessibleContext = null; |
3196 private ListModel<E> listModel; |
3196 private ListModel<E> listModel; |
3197 private ListCellRenderer<? super E> cellRenderer = null; |
3197 private ListCellRenderer<? super E> cellRenderer = null; |
3198 |
3198 |
3213 |
3213 |
3214 private Component getCurrentComponent() { |
3214 private Component getCurrentComponent() { |
3215 return getComponentAtIndex(indexInParent); |
3215 return getComponentAtIndex(indexInParent); |
3216 } |
3216 } |
3217 |
3217 |
3218 private AccessibleContext getCurrentAccessibleContext() { |
3218 AccessibleContext getCurrentAccessibleContext() { |
3219 Component c = getComponentAtIndex(indexInParent); |
3219 Component c = getComponentAtIndex(indexInParent); |
3220 if (c instanceof Accessible) { |
3220 if (c instanceof Accessible) { |
3221 return c.getAccessibleContext(); |
3221 return c.getAccessibleContext(); |
3222 } else { |
3222 } else { |
3223 return null; |
3223 return null; |
3379 if (ac != null) { |
3379 if (ac != null) { |
3380 ac.removePropertyChangeListener(l); |
3380 ac.removePropertyChangeListener(l); |
3381 } |
3381 } |
3382 } |
3382 } |
3383 |
3383 |
3384 public AccessibleAction getAccessibleAction() { |
|
3385 return getCurrentAccessibleContext().getAccessibleAction(); |
|
3386 } |
|
3387 |
|
3388 /** |
3384 /** |
3389 * Get the AccessibleComponent associated with this object. In the |
3385 * Get the AccessibleComponent associated with this object. In the |
3390 * implementation of the Java Accessibility API for this class, |
3386 * implementation of the Java Accessibility API for this class, |
3391 * return this object, which is responsible for implementing the |
3387 * return this object, which is responsible for implementing the |
3392 * AccessibleComponent interface on behalf of itself. |
3388 * AccessibleComponent interface on behalf of itself. |
3597 } |
3593 } |
3598 } |
3594 } |
3599 |
3595 |
3600 public Point getLocationOnScreen() { |
3596 public Point getLocationOnScreen() { |
3601 if (parent != null) { |
3597 if (parent != null) { |
3602 Point listLocation = parent.getLocationOnScreen(); |
3598 Point listLocation; |
|
3599 try { |
|
3600 listLocation = parent.getLocationOnScreen(); |
|
3601 } catch (IllegalComponentStateException e) { |
|
3602 // This can happen if the component isn't visisble |
|
3603 return null; |
|
3604 } |
3603 Point componentLocation = parent.indexToLocation(indexInParent); |
3605 Point componentLocation = parent.indexToLocation(indexInParent); |
3604 if (componentLocation != null) { |
3606 if (componentLocation != null) { |
3605 componentLocation.translate(listLocation.x, listLocation.y); |
3607 componentLocation.translate(listLocation.x, listLocation.y); |
3606 return componentLocation; |
3608 return componentLocation; |
3607 } else { |
3609 } else { |
3738 return ac.getAccessibleIcon(); |
3740 return ac.getAccessibleIcon(); |
3739 } else { |
3741 } else { |
3740 return null; |
3742 return null; |
3741 } |
3743 } |
3742 } |
3744 } |
|
3745 |
3743 } // inner class AccessibleJListChild |
3746 } // inner class AccessibleJListChild |
|
3747 |
|
3748 private class ActionableAccessibleJListChild |
|
3749 extends AccessibleJListChild |
|
3750 implements AccessibleAction { |
|
3751 |
|
3752 ActionableAccessibleJListChild(JList<E> parent, int indexInParent) { |
|
3753 super(parent, indexInParent); |
|
3754 } |
|
3755 |
|
3756 @Override |
|
3757 public AccessibleAction getAccessibleAction() { |
|
3758 AccessibleContext ac = getCurrentAccessibleContext(); |
|
3759 if (ac == null) { |
|
3760 return null; |
|
3761 } else { |
|
3762 AccessibleAction aa = ac.getAccessibleAction(); |
|
3763 if (aa != null) { |
|
3764 return aa; |
|
3765 } else { |
|
3766 return this; |
|
3767 } |
|
3768 } |
|
3769 } |
|
3770 |
|
3771 @Override |
|
3772 public boolean doAccessibleAction(int i) { |
|
3773 if (i == 0) { |
|
3774 JList.this.setSelectedIndex(indexInParent); |
|
3775 return true; |
|
3776 } else { |
|
3777 return false; |
|
3778 } |
|
3779 } |
|
3780 |
|
3781 @Override |
|
3782 public String getAccessibleActionDescription(int i) { |
|
3783 if (i == 0) { |
|
3784 return UIManager.getString("AbstractButton.clickText"); |
|
3785 } else { |
|
3786 return null; |
|
3787 } |
|
3788 } |
|
3789 |
|
3790 @Override |
|
3791 public int getAccessibleActionCount() { |
|
3792 return 1; |
|
3793 } |
|
3794 |
|
3795 } // inner class ActionableAccessibleJListChild |
|
3796 |
3744 } // inner class AccessibleJList |
3797 } // inner class AccessibleJList |
3745 } |
3798 } |