access.html

来自「jsf、swing的官方指南」· HTML 代码 · 共 1,331 行 · 第 1/4 页

HTML
1,331
字号
You've seen how to implement accessibilityfor two simple components,that exist only to paint themselves onscreen.Components that do more,such as responding to mouse or keyboard events,need to provide more elaborate accessible contexts.You can find examples of implementing accessible contextsby delving in the source code for the Swing components.</blockquote><h3><a name="api">The Accessibility API</a></h3><blockquote>The tables in this sectioncover just part of the accessibility API.For more information about the accessibility API,see the API documentation for the classes and packages in the<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/package-summary.html">accessibility package</a>.Also, refer to the API documentation forthe accessible contexts for individual Swing components.<p>The API for supporting accessibility falls into the following categories:<ul><li><a href="#settingnamesapi">Naming and Linking Components</a><li><a href="#accessibleapi">Making a Custom Component Accessible</a><li><a href="#interfaceList">Accessible Interfaces</a></ul><table border=1><caption><a name="settingnamesapi">Naming and Linking Components</a></caption><tr><th align=left>Method</th><th align=left>Purpose</th></tr> <tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleContext.html#setAccessibleName(java.lang.String)">getAccessibleContext().setAccessibleName(String)</a>    <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleContext.html#setAccessibleDescription(java.lang.String)">getAccessibleContext().setAccessibleDescription(String)</a>    <br>    (<em>on a <code>JComponent</code>     or <code>Accessible</code> object</em>)</td><td>Provide a name or description for an accessible object.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setToolTipText(java.lang.String)">void setToolTipText(String)</a>    <br>(<em>in <code>JComponent</code></em>)</td><td>Set a component's tool tip.    If you don't set the description,    than many accessible contexts use the tool-tip text    as the accessible description.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JLabel.html#setLabelFor(java.awt.Component)">void setLabelFor(Component)</a>    <br>(<em>in <code>JLabel</code></em>)</td><td>Associate a label with a component.    This tells assistive technologies    that a label describes another component.</td></tr><tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/ImageIcon.html#setDescription(java.lang.String)">void setDescription(String)</a>    </code>     <br>(<em>in <code>ImageIcon</code></em>)</td><td>Provide a description for an image icon.</td></tr></table><br><table border=1><caption><a name="accessibleapi">Making a Custom Component Accessible</a></caption><tr><th align=left>Interface or Class</th><th align=left>Purpose</th></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/Accessible.html">Accessible</a>    <br>(<em>an interface</em>)</td><td>Components that implement this interface are accessible.    Subclasses of <code>JComponent</code>    must implement this explicitly.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleContext.html">AccessibleContext</a>    <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.AccessibleJComponent.html"><em>JComponent</em>.Accessible<em>JComponent</em></a>    </code>     <br>(<em>an abstract class and its subclasses</em>) </td><td><code>AccessibleContext</code> defines the minimal    set of information required of accessible objects.    The accessible context for each Swing component is    a subclass of this and named as shown. For example,    the accessible context for <code>JTree</code> is    <code>JTree.AccessibleJTree</code>.    To provide custom accessible contexts,    custom components should contain an inner class    that is a subclass of <code>AccessibleContext</code>.    For more information, see    <a href="#accessiblecomponents">Making Custom    Components Accessible</a>.</tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleRole.html">AccessibleRole</a>    <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleStateSet.html">AccessibleStateSet</a>    <br>(<em>classes</em>)</td><td> Define the objects     returned by an <code>AccessibleContext</code> object's     <code>getAccessibleRole</code> and     <code>getAccessibleStateSet</code> methods,     respectively.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleRelation.html">AccessibleRelation</a>    <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleRelationSet.html">AccessibleRelationSet</a>    <br>(<em>classes introduced in 1.3</em>)</td><td>Define the relations between components that    implement this interface and one or more other    objects.</font></td></table><br><table border=1><caption><a name="interfaceList">Accessible Interfaces</a></caption><tr><th align=left>Interface</th><th align=left>Purpose</th></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleAction.html">AccessibleAction</a></td><td>Indicates that the object can perform actions.    By implementing this interface,    the accessible context can give information about    what actions the accessible object can perform    and can tell the accessible object to perform them.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleComponent.html">AccessibleComponent</a></td><td>Indicates that the accessible object has an onscreen presence.    Through this interface, an accessible object    can provide information about its size, position, visibility and so on.    The accessible contexts for all standard Swing components    implement this interface, directly or indirectly.    The accessible contexts for your custom components    should do the same.    As of 1.4, <code>AccessibleExtendedComponent</code> is preferred.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleEditableText.html">AccessibleEditableText</a>    <br><em>(Introduced in 1.4)</em></td><td>Indicates that the accessible object displays editable text.    In addition to the information available from its superinterface,    <code>AccessibleText</code>, methods are provided for cutting, pasting,    deleting, selecting, and inserting text.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleExtendedComponent.html">AccessibleExtendedComponent</a>    <br><em>(Introduced in 1.4)</em></td><td>In addition to the information available from its superinterface,    <code>AccessibleComponent</code>, methods are provided for obtaining    key bindings, border text, and tool-tip text.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleExtendedTable.html">AccessibleExtendedTable</a>    <br><em>(Introduced in 1.4)</em></td><td>In addition to the information available from its superinterface,    <code>AccessibleTable</code>, methods are provided to convert between an index    and its row or column.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleHypertext.html">AccessibleHypertext</a></td><td>Indicates that the accessible object contains hyperlinks.    Through this interface, an accessible object can provide    information about its links and allow them to be traversed.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleIcon.html">AccessibleIcon</a>    <br><em>(Introduced in 1.3)</em></td><td>Indicates that the accessible object has an associated icon.    Methods are provided that return information about the    icon, such as size and description.</td><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleKeyBinding.html">AccessibleKeyBinding</a>    <br><em>(Introduced in 1.4)</em></td><td>Indicates that the accessible object supports one or more    keyboard shortcuts that can be used to select the object.    Methods are provided that return the key bindings for a given object.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleSelection.html">AccessibleSelection</a></td><td>Indicates that the accessible object can contain a selection.    Accessible contexts that implement this interface can    report information about the current selection    and can modify the selection.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleTable.html">AccessibleTable</a>    <br><em>(Introduced in 1.3)</em></td><td>Indicates that the accessible object presents data in a two-dimensional    data object.  Through this interface information about the table such as    table caption, row and column size, description, and name are provided.     As of 1.4, <code>AccessibleExtendedTable</code> is preferred.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleText.html">AccessibleText</a></td><td>Indicates that the accessible object displays text.    This interface provides methods for returning all or part    of the text, attributes applied to it, and other information    about the text such as its length.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/accessibility/AccessibleValue.html">AccessibleValue</a></td><td>Indicates that the object has a numeric value.    Through this interface an accessible object     provides information about its current value    and its minimum and maximum values.</td></tr></table></blockquote> <h3> <a name="eg">Examples that Use the Accessibility API</a> </h3> <blockquote> The following table lists someof our examples that have good support for assistive technologies.<br><p><table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr><td> <a href="examples/index.html#AccessibleScrollDemo">     <code>AccessibleScrollDemo</code></a></td><td> This section</td><td> Contains two custom components     that implement the <code>Accessible</code> interface.     To see a less accessible version of this program see     <a href="../components/scrollpane.html">     How to Use Scroll Panes</a>.</td></tr><tr><td> <a href="../components/examples/index.html#ButtonDemo">     <code>ButtonDemo</code></a></td><td> <a class="TutorialLink" target="_top" href="../components/button.html#abstractbutton">How to Use the Common Button API</a></td><td> Uses three buttons.     Supports accessibility through button text, mnemonics, and tool tips.</td></tr></table>        </blockquote>        <div class=NavBit>            <a target=_top href=timer.html>&laquo; Previous</a>            &bull;            <a target=_top href=../TOC.html>Trail</a>            &bull;            <a target=_top href=focus.html>Next &raquo;</a>        </div>    </div>    <div id=Footer><div id=TagNotes>    Problems with the examples? Try <a target="_blank"        href=../../information/run-examples.html>Compiling and Running        the Examples: FAQs</a>.    <br>    Complaints? Compliments? Suggestions? <a target="_blank"        href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give    us your feedback</a>.<br><br>    <a target="_blank" href="../../information/copyright.html">Copyright</a>    1995-2006 Sun Microsystems, Inc.  All rights reserved.    <span id=Download></span></div>     </div>    <div class=PrintHeaders>        <b>Previous page:</b> How to Use Swing Timers        <br><b>Next page:</b> How to Use the Focus Subsystem    </div>    </body></html> 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?