1 /* 2 * Copyright (c) 1997, 2020, 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 23 * questions. 24 */ 25 26 package javax.accessibility; 27 28 import java.awt.IllegalComponentStateException; 29 import java.beans.BeanProperty; 30 import java.beans.JavaBean; 31 import java.beans.PropertyChangeEvent; 32 import java.beans.PropertyChangeListener; 33 import java.beans.PropertyChangeSupport; 34 import java.util.Locale; 35 36 import sun.awt.AWTAccessor; 37 import sun.awt.AppContext; 38 39 /** 40 * {@code AccessibleContext} represents the minimum information all accessible 41 * objects return. This information includes the accessible name, description, 42 * role, and state of the object, as well as information about its parent and 43 * children. {@code AccessibleContext} also contains methods for obtaining more 44 * specific accessibility information about a component. If the component 45 * supports them, these methods will return an object that implements one or 46 * more of the following interfaces: 47 * <ul> 48 * <li>{@link AccessibleAction} - the object can perform one or more actions. 49 * This interface provides the standard mechanism for an assistive technology 50 * to determine what those actions are and tell the object to perform them. 51 * Any object that can be manipulated should support this interface. 52 * <li>{@link AccessibleComponent} - the object has a graphical 53 * representation. This interface provides the standard mechanism for an 54 * assistive technology to determine and set the graphical representation of 55 * the object. Any object that is rendered on the screen should support this 56 * interface. 57 * <li>{@link AccessibleSelection} - the object allows its children to be 58 * selected. This interface provides the standard mechanism for an assistive 59 * technology to determine the currently selected children of the object as 60 * well as modify its selection set. Any object that has children that can be 61 * selected should support this interface. 62 * <li>{@link AccessibleText} - the object presents editable textual 63 * information on the display. This interface provides the standard mechanism 64 * for an assistive technology to access that text via its content, 65 * attributes, and spatial location. Any object that contains editable text 66 * should support this interface. 67 * <li>{@link AccessibleValue} - the object supports a numerical value. This 68 * interface provides the standard mechanism for an assistive technology to 69 * determine and set the current value of the object, as well as obtain its 70 * minimum and maximum values. Any object that supports a numerical value 71 * should support this interface. 72 * </ul> 73 * 74 * @author Peter Korn 75 * @author Hans Muller 76 * @author Willie Walker 77 * @author Lynn Monsanto 78 */ 79 @JavaBean(description = "Minimal information that all accessible objects return") 80 public abstract class AccessibleContext { 81 82 /** 83 * Constructor for subclasses to call. 84 */ AccessibleContext()85 protected AccessibleContext() {} 86 87 /** 88 * The {@code AppContext} that should be used to dispatch events for this 89 * {@code AccessibleContext}. 90 */ 91 private volatile AppContext targetAppContext; 92 93 static { AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() { @Override public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) { accessibleContext.targetAppContext = appContext; } @Override public AppContext getAppContext(AccessibleContext accessibleContext) { return accessibleContext.targetAppContext; } @Override public Object getNativeAXResource(AccessibleContext accessibleContext) { return accessibleContext.nativeAXResource; } @Override public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { accessibleContext.nativeAXResource = value; } })94 AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() { 95 @Override 96 public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) { 97 accessibleContext.targetAppContext = appContext; 98 } 99 100 @Override 101 public AppContext getAppContext(AccessibleContext accessibleContext) { 102 return accessibleContext.targetAppContext; 103 } 104 105 @Override 106 public Object getNativeAXResource(AccessibleContext accessibleContext) { 107 return accessibleContext.nativeAXResource; 108 } 109 110 @Override 111 public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { 112 accessibleContext.nativeAXResource = value; 113 } 114 }); 115 } 116 117 /** 118 * Constant used to determine when the {@link #accessibleName} property has 119 * changed. The old value in the {@code PropertyChangeEvent} will be the old 120 * {@code accessibleName} and the new value will be the new 121 * {@code accessibleName}. 122 * 123 * @see #getAccessibleName 124 * @see #addPropertyChangeListener 125 */ 126 public static final String ACCESSIBLE_NAME_PROPERTY = "AccessibleName"; 127 128 /** 129 * Constant used to determine when the {@link #accessibleDescription} 130 * property has changed. The old value in the {@code PropertyChangeEvent} 131 * will be the old {@code accessibleDescription} and the new value will be 132 * the new {@code accessibleDescription}. 133 * 134 * @see #getAccessibleDescription 135 * @see #addPropertyChangeListener 136 */ 137 public static final String ACCESSIBLE_DESCRIPTION_PROPERTY = "AccessibleDescription"; 138 139 /** 140 * Constant used to determine when the {@code accessibleStateSet} property 141 * has changed. The old value will be the old {@code AccessibleState} and 142 * the new value will be the new {@code AccessibleState} in the 143 * {@code accessibleStateSet}. For example, if a component that supports the 144 * vertical and horizontal states changes its orientation from vertical to 145 * horizontal, the old value will be {@code AccessibleState.VERTICAL} and 146 * the new value will be {@code AccessibleState.HORIZONTAL}. Please note 147 * that either value can also be {@code null}. For example, when a component 148 * changes from being enabled to disabled, the old value will be 149 * {@code AccessibleState.ENABLED} and the new value will be {@code null}. 150 * 151 * @see #getAccessibleStateSet 152 * @see AccessibleState 153 * @see AccessibleStateSet 154 * @see #addPropertyChangeListener 155 */ 156 public static final String ACCESSIBLE_STATE_PROPERTY = "AccessibleState"; 157 158 /** 159 * Constant used to determine when the {@code accessibleValue} property has 160 * changed. The old value in the {@code PropertyChangeEvent} will be a 161 * {@code Number} representing the old value and the new value will be a 162 * {@code Number} representing the new value. 163 * 164 * @see #getAccessibleValue 165 * @see #addPropertyChangeListener 166 */ 167 public static final String ACCESSIBLE_VALUE_PROPERTY = "AccessibleValue"; 168 169 /** 170 * Constant used to determine when the {@code accessibleSelection} has 171 * changed. The old and new values in the {@code PropertyChangeEvent} are 172 * currently reserved for future use. 173 * 174 * @see #getAccessibleSelection 175 * @see #addPropertyChangeListener 176 */ 177 public static final String ACCESSIBLE_SELECTION_PROPERTY = "AccessibleSelection"; 178 179 /** 180 * Constant used to determine when the {@code accessibleText} caret has 181 * changed. The old value in the {@code PropertyChangeEvent} will be an 182 * integer representing the old caret position, and the new value will be an 183 * integer representing the new/current caret position. 184 * 185 * @see #addPropertyChangeListener 186 */ 187 public static final String ACCESSIBLE_CARET_PROPERTY = "AccessibleCaret"; 188 189 /** 190 * Constant used to determine when the visual appearance of the object has 191 * changed. The old and new values in the {@code PropertyChangeEvent} are 192 * currently reserved for future use. 193 * 194 * @see #addPropertyChangeListener 195 */ 196 public static final String ACCESSIBLE_VISIBLE_DATA_PROPERTY = "AccessibleVisibleData"; 197 198 /** 199 * Constant used to determine when {@code Accessible} children are 200 * added/removed from the object. If an {@code Accessible} child is being 201 * added, the old value will be {@code null} and the new value will be the 202 * {@code Accessible} child. If an {@code Accessible} child is being 203 * removed, the old value will be the {@code Accessible} child, and the new 204 * value will be {@code null}. 205 * 206 * @see #addPropertyChangeListener 207 */ 208 public static final String ACCESSIBLE_CHILD_PROPERTY = "AccessibleChild"; 209 210 /** 211 * Constant used to determine when the active descendant of a component has 212 * changed. The active descendant is used for objects such as list, tree, 213 * and table, which may have transient children. When the active descendant 214 * has changed, the old value of the property change event will be the 215 * {@code Accessible} representing the previous active child, and the new 216 * value will be the {@code Accessible} representing the current active 217 * child. 218 * 219 * @see #addPropertyChangeListener 220 */ 221 public static final String ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY = "AccessibleActiveDescendant"; 222 223 /** 224 * Constant used to indicate that the table caption has changed. The old 225 * value in the {@code PropertyChangeEvent} will be an {@code Accessible} 226 * representing the previous table caption and the new value will be an 227 * {@code Accessible} representing the new table caption. 228 * 229 * @see Accessible 230 * @see AccessibleTable 231 */ 232 public static final String ACCESSIBLE_TABLE_CAPTION_CHANGED = 233 "accessibleTableCaptionChanged"; 234 235 /** 236 * Constant used to indicate that the table summary has changed. The old 237 * value in the {@code PropertyChangeEvent} will be an {@code Accessible} 238 * representing the previous table summary and the new value will be an 239 * {@code Accessible} representing the new table summary. 240 * 241 * @see Accessible 242 * @see AccessibleTable 243 */ 244 public static final String ACCESSIBLE_TABLE_SUMMARY_CHANGED = 245 "accessibleTableSummaryChanged"; 246 247 /** 248 * Constant used to indicate that table data has changed. The old value in 249 * the {@code PropertyChangeEvent} will be {@code null} and the new value 250 * will be an {@code AccessibleTableModelChange} representing the table 251 * change. 252 * 253 * @see AccessibleTable 254 * @see AccessibleTableModelChange 255 */ 256 public static final String ACCESSIBLE_TABLE_MODEL_CHANGED = 257 "accessibleTableModelChanged"; 258 259 /** 260 * Constant used to indicate that the row header has changed. The old value 261 * in the {@code PropertyChangeEvent} will be {@code null} and the new value 262 * will be an {@code AccessibleTableModelChange} representing the header 263 * change. 264 * 265 * @see AccessibleTable 266 * @see AccessibleTableModelChange 267 */ 268 public static final String ACCESSIBLE_TABLE_ROW_HEADER_CHANGED = 269 "accessibleTableRowHeaderChanged"; 270 271 /** 272 * Constant used to indicate that the row description has changed. The old 273 * value in the {@code PropertyChangeEvent} will be {@code null} and the new 274 * value will be an {@code Integer} representing the row index. 275 * 276 * @see AccessibleTable 277 */ 278 public static final String ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED = 279 "accessibleTableRowDescriptionChanged"; 280 281 /** 282 * Constant used to indicate that the column header has changed. The old 283 * value in the {@code PropertyChangeEvent} will be {@code null} and the new 284 * value will be an {@code AccessibleTableModelChange} representing the 285 * header change. 286 * 287 * @see AccessibleTable 288 * @see AccessibleTableModelChange 289 */ 290 public static final String ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED = 291 "accessibleTableColumnHeaderChanged"; 292 293 /** 294 * Constant used to indicate that the column description has changed. The 295 * old value in the {@code PropertyChangeEvent} will be {@code null} and the 296 * new value will be an {@code Integer} representing the column index. 297 * 298 * @see AccessibleTable 299 */ 300 public static final String ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED = 301 "accessibleTableColumnDescriptionChanged"; 302 303 /** 304 * Constant used to indicate that the supported set of actions has changed. 305 * The old value in the {@code PropertyChangeEvent} will be an 306 * {@code Integer} representing the old number of actions supported and the 307 * new value will be an {@code Integer} representing the new number of 308 * actions supported. 309 * 310 * @see AccessibleAction 311 */ 312 public static final String ACCESSIBLE_ACTION_PROPERTY = 313 "accessibleActionProperty"; 314 315 /** 316 * Constant used to indicate that a hypertext element has received focus. 317 * The old value in the {@code PropertyChangeEvent} will be an 318 * {@code Integer} representing the start index in the document of the 319 * previous element that had focus and the new value will be an 320 * {@code Integer} representing the start index in the document of the 321 * current element that has focus. A value of -1 indicates that an element 322 * does not or did not have focus. 323 * 324 * @see AccessibleHyperlink 325 */ 326 public static final String ACCESSIBLE_HYPERTEXT_OFFSET = 327 "AccessibleHypertextOffset"; 328 329 /** 330 * {@code PropertyChangeEvent} which indicates that text has changed. 331 * <br> 332 * For text insertion, the {@code oldValue} is {@code null} and the 333 * {@code newValue} is an {@code AccessibleTextSequence} specifying the text 334 * that was inserted. 335 * <br> 336 * For text deletion, the {@code oldValue} is an 337 * {@code AccessibleTextSequence} specifying the text that was deleted and 338 * the {@code newValue} is {@code null}. 339 * <br> 340 * For text replacement, the {@code oldValue} is an 341 * {@code AccessibleTextSequence} specifying the old text and the 342 * {@code newValue} is an {@code AccessibleTextSequence} specifying the new 343 * text. 344 * 345 * @see #getAccessibleText 346 * @see #addPropertyChangeListener 347 * @see AccessibleTextSequence 348 */ 349 public static final String ACCESSIBLE_TEXT_PROPERTY 350 = "AccessibleText"; 351 352 /** 353 * {@code PropertyChangeEvent} which indicates that a significant change has 354 * occurred to the children of a component like a tree or text. This change 355 * notifies the event listener that it needs to reacquire the state of the 356 * subcomponents. The {@code oldValue} is {@code null} and the 357 * {@code newValue} is the component whose children have become invalid. 358 * 359 * @see #getAccessibleText 360 * @see #addPropertyChangeListener 361 * @see AccessibleTextSequence 362 * @since 1.5 363 */ 364 public static final String ACCESSIBLE_INVALIDATE_CHILDREN = 365 "accessibleInvalidateChildren"; 366 367 /** 368 * {@code PropertyChangeEvent} which indicates that text attributes have 369 * changed. 370 * <br> 371 * For attribute insertion, the {@code oldValue} is {@code null} and the 372 * {@code newValue} is an {@code AccessibleAttributeSequence} specifying the 373 * attributes that were inserted. 374 * <br> 375 * For attribute deletion, the {@code oldValue} is an 376 * {@code AccessibleAttributeSequence} specifying the attributes that were 377 * deleted and the {@code newValue} is {@code null}. 378 * <br> 379 * For attribute replacement, the {@code oldValue} is an 380 * {@code AccessibleAttributeSequence} specifying the old attributes and the 381 * {@code newValue} is an {@code AccessibleAttributeSequence} specifying the 382 * new attributes. 383 * 384 * @see #getAccessibleText 385 * @see #addPropertyChangeListener 386 * @see AccessibleAttributeSequence 387 * @since 1.5 388 */ 389 public static final String ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED = 390 "accessibleTextAttributesChanged"; 391 392 /** 393 * {@code PropertyChangeEvent} which indicates that a change has occurred in 394 * a component's bounds. The {@code oldValue} is the old component bounds 395 * and the {@code newValue} is the new component bounds. 396 * 397 * @see #addPropertyChangeListener 398 * @since 1.5 399 */ 400 public static final String ACCESSIBLE_COMPONENT_BOUNDS_CHANGED = 401 "accessibleComponentBoundsChanged"; 402 403 /** 404 * The accessible parent of this object. 405 * 406 * @see #getAccessibleParent 407 * @see #setAccessibleParent 408 */ 409 protected Accessible accessibleParent = null; 410 411 /** 412 * A localized String containing the name of the object. 413 * 414 * @see #getAccessibleName 415 * @see #setAccessibleName 416 */ 417 protected String accessibleName = null; 418 419 /** 420 * A localized String containing the description of the object. 421 * 422 * @see #getAccessibleDescription 423 * @see #setAccessibleDescription 424 */ 425 protected String accessibleDescription = null; 426 427 /** 428 * Used to handle the listener list for property change events. 429 * 430 * @see #addPropertyChangeListener 431 * @see #removePropertyChangeListener 432 * @see #firePropertyChange 433 */ 434 private PropertyChangeSupport accessibleChangeSupport = null; 435 436 /** 437 * Used to represent the context's relation set. 438 * 439 * @see #getAccessibleRelationSet 440 */ 441 private AccessibleRelationSet relationSet 442 = new AccessibleRelationSet(); 443 444 private Object nativeAXResource; 445 446 /** 447 * Gets the {@code accessibleName} property of this object. The 448 * {@code accessibleName} property of an object is a localized 449 * {@code String} that designates the purpose of the object. For example, 450 * the {@code accessibleName} property of a label or button might be the 451 * text of the label or button itself. In the case of an object that doesn't 452 * display its name, the {@code accessibleName} should still be set. For 453 * example, in the case of a text field used to enter the name of a city, 454 * the {@code accessibleName} for the {@code en_US} locale could be 'city.' 455 * 456 * @return the localized name of the object; {@code null} if this object 457 * does not have a name 458 * @see #setAccessibleName 459 */ getAccessibleName()460 public String getAccessibleName() { 461 return accessibleName; 462 } 463 464 /** 465 * Sets the localized accessible name of this object. Changing the name will 466 * cause a {@code PropertyChangeEvent} to be fired for the 467 * {@code ACCESSIBLE_NAME_PROPERTY} property. 468 * 469 * @param s the new localized name of the object 470 * @see #getAccessibleName 471 * @see #addPropertyChangeListener 472 */ 473 @BeanProperty(preferred = true, description 474 = "Sets the accessible name for the component.") setAccessibleName(String s)475 public void setAccessibleName(String s) { 476 String oldName = accessibleName; 477 accessibleName = s; 478 firePropertyChange(ACCESSIBLE_NAME_PROPERTY,oldName,accessibleName); 479 } 480 481 /** 482 * Gets the {@code accessibleDescription} property of this object. The 483 * {@code accessibleDescription} property of this object is a short 484 * localized phrase describing the purpose of the object. For example, in 485 * the case of a 'Cancel' button, the {@code accessibleDescription} could be 486 * 'Ignore changes and close dialog box.' 487 * 488 * @return the localized description of the object; {@code null} if this 489 * object does not have a description 490 * @see #setAccessibleDescription 491 */ getAccessibleDescription()492 public String getAccessibleDescription() { 493 return accessibleDescription; 494 } 495 496 /** 497 * Sets the accessible description of this object. Changing the name will 498 * cause a {@code PropertyChangeEvent} to be fired for the 499 * {@code ACCESSIBLE_DESCRIPTION_PROPERTY} property. 500 * 501 * @param s the new localized description of the object 502 * @see #setAccessibleName 503 * @see #addPropertyChangeListener 504 */ 505 @BeanProperty(preferred = true, description 506 = "Sets the accessible description for the component.") setAccessibleDescription(String s)507 public void setAccessibleDescription(String s) { 508 String oldDescription = accessibleDescription; 509 accessibleDescription = s; 510 firePropertyChange(ACCESSIBLE_DESCRIPTION_PROPERTY, 511 oldDescription,accessibleDescription); 512 } 513 514 /** 515 * Gets the role of this object. The role of the object is the generic 516 * purpose or use of the class of this object. For example, the role of a 517 * push button is {@code AccessibleRole.PUSH_BUTTON}. The roles in 518 * {@code AccessibleRole} are provided so component developers can pick from 519 * a set of predefined roles. This enables assistive technologies to provide 520 * a consistent interface to various tweaked subclasses of components (e.g., 521 * use {@code AccessibleRole.PUSH_BUTTON} for all components that act like a 522 * push button) as well as distinguish between subclasses that behave 523 * differently (e.g., {@code AccessibleRole.CHECK_BOX} for check boxes and 524 * {@code AccessibleRole.RADIO_BUTTON} for radio buttons). 525 * <p> 526 * Note that the {@code AccessibleRole} class is also extensible, so custom 527 * component developers can define their own {@code AccessibleRole}'s if the 528 * set of predefined roles is inadequate. 529 * 530 * @return an instance of {@code AccessibleRole} describing the role of the 531 * object 532 * @see AccessibleRole 533 */ getAccessibleRole()534 public abstract AccessibleRole getAccessibleRole(); 535 536 /** 537 * Gets the state set of this object. The {@code AccessibleStateSet} of an 538 * object is composed of a set of unique {@code AccessibleStates}. A change 539 * in the {@code AccessibleStateSet} of an object will cause a 540 * {@code PropertyChangeEvent} to be fired for the 541 * {@code ACCESSIBLE_STATE_PROPERTY} property. 542 * 543 * @return an instance of {@code AccessibleStateSet} containing the current 544 * state set of the object 545 * @see AccessibleStateSet 546 * @see AccessibleState 547 * @see #addPropertyChangeListener 548 */ getAccessibleStateSet()549 public abstract AccessibleStateSet getAccessibleStateSet(); 550 551 /** 552 * Gets the {@code Accessible} parent of this object. 553 * 554 * @return the {@code Accessible} parent of this object; {@code null} if 555 * this object does not have an {@code Accessible} parent 556 */ getAccessibleParent()557 public Accessible getAccessibleParent() { 558 return accessibleParent; 559 } 560 561 /** 562 * Sets the {@code Accessible} parent of this object. This is meant to be 563 * used only in the situations where the actual component's parent should 564 * not be treated as the component's accessible parent and is a method that 565 * should only be called by the parent of the accessible child. 566 * 567 * @param a - {@code Accessible} to be set as the parent 568 */ setAccessibleParent(Accessible a)569 public void setAccessibleParent(Accessible a) { 570 accessibleParent = a; 571 } 572 573 /** 574 * Gets the 0-based index of this object in its accessible parent. 575 * 576 * @return the 0-based index of this object in its parent; -1 if this object 577 * does not have an accessible parent. 578 * @see #getAccessibleParent 579 * @see #getAccessibleChildrenCount 580 * @see #getAccessibleChild 581 */ getAccessibleIndexInParent()582 public abstract int getAccessibleIndexInParent(); 583 584 /** 585 * Returns the number of accessible children of the object. 586 * 587 * @return the number of accessible children of the object. 588 */ getAccessibleChildrenCount()589 public abstract int getAccessibleChildrenCount(); 590 591 /** 592 * Returns the specified {@code Accessible} child of the object. The 593 * {@code Accessible} children of an {@code Accessible} object are 594 * zero-based, so the first child of an {@code Accessible} child is at index 595 * 0, the second child is at index 1, and so on. 596 * 597 * @param i zero-based index of child 598 * @return the {@code Accessible} child of the object 599 * @see #getAccessibleChildrenCount 600 */ getAccessibleChild(int i)601 public abstract Accessible getAccessibleChild(int i); 602 603 /** 604 * Gets the locale of the component. If the component does not have a 605 * locale, then the locale of its parent is returned. 606 * 607 * @return this component's locale. If this component does not have a 608 * locale, the locale of its parent is returned. 609 * @throws IllegalComponentStateException If the component does not have its 610 * own locale and has not yet been added to a containment hierarchy 611 * such that the locale can be determined from the containing 612 * parent 613 */ getLocale()614 public abstract Locale getLocale() throws IllegalComponentStateException; 615 616 /** 617 * Adds a {@code PropertyChangeListener} to the listener list. The listener 618 * is registered for all {@code Accessible} properties and will be called 619 * when those properties change. 620 * 621 * @param listener The PropertyChangeListener to be added 622 * @see #ACCESSIBLE_NAME_PROPERTY 623 * @see #ACCESSIBLE_DESCRIPTION_PROPERTY 624 * @see #ACCESSIBLE_STATE_PROPERTY 625 * @see #ACCESSIBLE_VALUE_PROPERTY 626 * @see #ACCESSIBLE_SELECTION_PROPERTY 627 * @see #ACCESSIBLE_TEXT_PROPERTY 628 * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY 629 */ addPropertyChangeListener(PropertyChangeListener listener)630 public void addPropertyChangeListener(PropertyChangeListener listener) { 631 if (accessibleChangeSupport == null) { 632 accessibleChangeSupport = new PropertyChangeSupport(this); 633 } 634 accessibleChangeSupport.addPropertyChangeListener(listener); 635 } 636 637 /** 638 * Removes a {@code PropertyChangeListener} from the listener list. This 639 * removes a {@code PropertyChangeListener} that was registered for all 640 * properties. 641 * 642 * @param listener The PropertyChangeListener to be removed 643 */ removePropertyChangeListener(PropertyChangeListener listener)644 public void removePropertyChangeListener(PropertyChangeListener listener) { 645 if (accessibleChangeSupport != null) { 646 accessibleChangeSupport.removePropertyChangeListener(listener); 647 } 648 } 649 650 /** 651 * Gets the {@code AccessibleAction} associated with this object that 652 * supports one or more actions. 653 * 654 * @return {@code AccessibleAction} if supported by object; else return 655 * {@code null} 656 * @see AccessibleAction 657 */ getAccessibleAction()658 public AccessibleAction getAccessibleAction() { 659 return null; 660 } 661 662 /** 663 * Gets the {@code AccessibleComponent} associated with this object that has 664 * a graphical representation. 665 * 666 * @return {@code AccessibleComponent} if supported by object; else return 667 * {@code null} 668 * @see AccessibleComponent 669 */ getAccessibleComponent()670 public AccessibleComponent getAccessibleComponent() { 671 return null; 672 } 673 674 /** 675 * Gets the {@code AccessibleSelection} associated with this object which 676 * allows its {@code Accessible} children to be selected. 677 * 678 * @return {@code AccessibleSelection} if supported by object; else return 679 * {@code null} 680 * @see AccessibleSelection 681 */ getAccessibleSelection()682 public AccessibleSelection getAccessibleSelection() { 683 return null; 684 } 685 686 /** 687 * Gets the {@code AccessibleText} associated with this object presenting 688 * text on the display. 689 * 690 * @return {@code AccessibleText} if supported by object; else return 691 * {@code null} 692 * @see AccessibleText 693 */ getAccessibleText()694 public AccessibleText getAccessibleText() { 695 return null; 696 } 697 698 /** 699 * Gets the {@code AccessibleEditableText} associated with this object 700 * presenting editable text on the display. 701 * 702 * @return {@code AccessibleEditableText} if supported by object; else 703 * return {@code null} 704 * @see AccessibleEditableText 705 * @since 1.4 706 */ getAccessibleEditableText()707 public AccessibleEditableText getAccessibleEditableText() { 708 return null; 709 } 710 711 /** 712 * Gets the {@code AccessibleValue} associated with this object that 713 * supports a {@code Numerical} value. 714 * 715 * @return {@code AccessibleValue} if supported by object; else return 716 * {@code null} 717 * @see AccessibleValue 718 */ getAccessibleValue()719 public AccessibleValue getAccessibleValue() { 720 return null; 721 } 722 723 /** 724 * Gets the {@code AccessibleIcons} associated with an object that has one 725 * or more associated icons. 726 * 727 * @return an array of {@code AccessibleIcon} if supported by object; 728 * otherwise return {@code null} 729 * @see AccessibleIcon 730 * @since 1.3 731 */ getAccessibleIcon()732 public AccessibleIcon [] getAccessibleIcon() { 733 return null; 734 } 735 736 /** 737 * Gets the {@code AccessibleRelationSet} associated with an object. 738 * 739 * @return an {@code AccessibleRelationSet} if supported by object; 740 * otherwise return {@code null} 741 * @see AccessibleRelationSet 742 * @since 1.3 743 */ getAccessibleRelationSet()744 public AccessibleRelationSet getAccessibleRelationSet() { 745 return relationSet; 746 } 747 748 /** 749 * Gets the {@code AccessibleTable} associated with an object. 750 * 751 * @return an {@code AccessibleTable} if supported by object; otherwise return 752 * {@code null} 753 * @see AccessibleTable 754 * @since 1.3 755 */ getAccessibleTable()756 public AccessibleTable getAccessibleTable() { 757 return null; 758 } 759 760 /** 761 * Support for reporting bound property changes. If {@code oldValue} and 762 * {@code newValue} are not equal and the {@code PropertyChangeEvent} 763 * listener list is not empty, then fire a {@code PropertyChange} event to 764 * each listener. In general, this is for use by the {@code Accessible} 765 * objects themselves and should not be called by an application program. 766 * 767 * @param propertyName The programmatic name of the property that was 768 * changed 769 * @param oldValue The old value of the property 770 * @param newValue The new value of the property 771 * @see PropertyChangeSupport 772 * @see #addPropertyChangeListener 773 * @see #removePropertyChangeListener 774 * @see #ACCESSIBLE_NAME_PROPERTY 775 * @see #ACCESSIBLE_DESCRIPTION_PROPERTY 776 * @see #ACCESSIBLE_STATE_PROPERTY 777 * @see #ACCESSIBLE_VALUE_PROPERTY 778 * @see #ACCESSIBLE_SELECTION_PROPERTY 779 * @see #ACCESSIBLE_TEXT_PROPERTY 780 * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY 781 */ firePropertyChange(String propertyName, Object oldValue, Object newValue)782 public void firePropertyChange(String propertyName, 783 Object oldValue, 784 Object newValue) { 785 if (accessibleChangeSupport != null) { 786 if (newValue instanceof PropertyChangeEvent) { 787 PropertyChangeEvent pce = (PropertyChangeEvent)newValue; 788 accessibleChangeSupport.firePropertyChange(pce); 789 } else { 790 accessibleChangeSupport.firePropertyChange(propertyName, 791 oldValue, 792 newValue); 793 } 794 } 795 } 796 } 797