<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSwing_JFC%2FAccessible</id>
		<title>Java/Swing JFC/Accessible - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSwing_JFC%2FAccessible"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_JFC/Accessible&amp;action=history"/>
		<updated>2026-04-07T17:08:52Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Swing_JFC/Accessible&amp;diff=7331&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_JFC/Accessible&amp;diff=7331&amp;oldid=prev"/>
				<updated>2010-06-01T06:39:06Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:39, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Swing_JFC/Accessible&amp;diff=7330&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_JFC/Accessible&amp;diff=7330&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A GUI to show accessible information coming from the components in an ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java Swing, 2nd Edition&lt;br /&gt;
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole&lt;br /&gt;
ISBN: 0-596-00408-7&lt;br /&gt;
Publisher: O&amp;quot;Reilly &lt;br /&gt;
*/&lt;br /&gt;
// AssistiveExample.java&lt;br /&gt;
//A GUI to show accessible information coming from the components in an&lt;br /&gt;
//application. See BigExample.java for example of how to use this class.&lt;br /&gt;
//&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import javax.swing.border.*;&lt;br /&gt;
import javax.accessibility.*;&lt;br /&gt;
import javax.accessibility.util.*;&lt;br /&gt;
public class BigExample extends JFrame {&lt;br /&gt;
  public BigExample() {&lt;br /&gt;
    super(&amp;quot;Big Accessibility Example&amp;quot;);&lt;br /&gt;
    setSize(700,500);&lt;br /&gt;
    setDefaultCloseOperation(EXIT_ON_CLOSE);&lt;br /&gt;
    JMenuBar jmb = new JMenuBar();&lt;br /&gt;
    JMenu fileMenu = new JMenu(&amp;quot;File&amp;quot;);&lt;br /&gt;
    JMenuItem openItem = new JMenuItem(&amp;quot;Open&amp;quot;);&lt;br /&gt;
    JMenuItem saveItem = new JMenuItem(&amp;quot;Save&amp;quot;);&lt;br /&gt;
    JMenuItem exitItem = new JMenuItem(&amp;quot;Exit&amp;quot;);&lt;br /&gt;
    exitItem.addActionListener(new ActionListener() {&lt;br /&gt;
      public void actionPerformed(ActionEvent ae) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    fileMenu.add(openItem);&lt;br /&gt;
    fileMenu.add(saveItem);&lt;br /&gt;
    fileMenu.add(new JSeparator());&lt;br /&gt;
    fileMenu.add(exitItem);&lt;br /&gt;
    jmb.add(fileMenu);&lt;br /&gt;
    setJMenuBar(jmb);&lt;br /&gt;
    JTextArea jta = new JTextArea(&amp;quot;[Notes]\n&amp;quot;);&lt;br /&gt;
    JScrollPane sp1 = new JScrollPane(jta);&lt;br /&gt;
    sp1.setMinimumSize(new Dimension(200,200));&lt;br /&gt;
    sp1.setPreferredSize(new Dimension(200,200));&lt;br /&gt;
    String[] titles = { &amp;quot;Name&amp;quot;, &amp;quot;Start Date&amp;quot;, &amp;quot;Job Title&amp;quot; };&lt;br /&gt;
    String[][] data = {&lt;br /&gt;
      {&amp;quot;Jordan&amp;quot;, &amp;quot;2001&amp;quot;, &amp;quot;Director&amp;quot;},&lt;br /&gt;
      {&amp;quot;Naveen&amp;quot;, &amp;quot;1999&amp;quot;, &amp;quot;Programmer&amp;quot;},&lt;br /&gt;
      {&amp;quot;Jia&amp;quot;, &amp;quot;2000&amp;quot;, &amp;quot;Analyst&amp;quot;},&lt;br /&gt;
      {&amp;quot;Brooks&amp;quot;, &amp;quot;1998&amp;quot;, &amp;quot;Evangelist&amp;quot;}&lt;br /&gt;
    };&lt;br /&gt;
    JTable table = new JTable(data, titles);&lt;br /&gt;
    table.getAccessibleContext().setAccessibleDescription(&amp;quot;Employee Statistics&amp;quot;);&lt;br /&gt;
    JPanel rightPane = new JPanel(new BorderLayout());&lt;br /&gt;
    rightPane.add(new JScrollPane(table), BorderLayout.CENTER);&lt;br /&gt;
    rightPane.add(new JLabel(new ImageIcon(&amp;quot;logo.gif&amp;quot;)), BorderLayout.SOUTH);&lt;br /&gt;
    JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, rightPane);&lt;br /&gt;
    getContentPane().add(jsp, BorderLayout.CENTER);&lt;br /&gt;
    JPanel bPane = new JPanel();&lt;br /&gt;
    JButton okButton = new JButton(&amp;quot;Ok&amp;quot;);&lt;br /&gt;
    JButton applyButton = new JButton(&amp;quot;Apply&amp;quot;);&lt;br /&gt;
    JButton clearButton = new JButton(&amp;quot;Clear&amp;quot;);&lt;br /&gt;
    bPane.add(okButton);&lt;br /&gt;
    bPane.add(applyButton);&lt;br /&gt;
    bPane.add(clearButton);&lt;br /&gt;
    getContentPane().add(bPane, BorderLayout.SOUTH);&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    new BigExample();&lt;br /&gt;
    new AssistiveExample();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class AssistiveExample extends JPanel implements MouseMotionListener,&lt;br /&gt;
    ActionListener, GUIInitializedListener {&lt;br /&gt;
  Timer timer;&lt;br /&gt;
  static JFrame frame;&lt;br /&gt;
  JLabel nameLabel = new JLabel();&lt;br /&gt;
  JLabel descriptionLabel = new JLabel();&lt;br /&gt;
  JLabel tableLabel = new JLabel();&lt;br /&gt;
  JCheckBox selectionCheckBox = new JCheckBox(&amp;quot;Selection&amp;quot;, false);&lt;br /&gt;
  JCheckBox textCheckBox = new JCheckBox(&amp;quot;Text&amp;quot;, false);&lt;br /&gt;
  JCheckBox valueCheckBox = new JCheckBox(&amp;quot;Value&amp;quot;, false);&lt;br /&gt;
  JCheckBox componentCheckBox = new JCheckBox(&amp;quot;Component&amp;quot;, false);&lt;br /&gt;
  JCheckBox actionCheckBox = new JCheckBox(&amp;quot;Action&amp;quot;, false);&lt;br /&gt;
  JCheckBox hypertextCheckBox = new JCheckBox(&amp;quot;Hypertext&amp;quot;, false);&lt;br /&gt;
  JCheckBox iconCheckBox = new JCheckBox(&amp;quot;Icon&amp;quot;, false);&lt;br /&gt;
  JCheckBox tableCheckBox = new JCheckBox(&amp;quot;Table&amp;quot;, false);&lt;br /&gt;
  JCheckBox editableTextCheckBox = new JCheckBox(&amp;quot;EditableText&amp;quot;, false);&lt;br /&gt;
  JLabel classLabel = new JLabel();&lt;br /&gt;
  JLabel parentLabel = new JLabel();&lt;br /&gt;
  JLabel relationLabel = new JLabel();&lt;br /&gt;
  JButton performAction = new JButton(&amp;quot;Perform Action&amp;quot;);&lt;br /&gt;
  public AssistiveExample() {&lt;br /&gt;
    frame = new JFrame(&amp;quot;Assistive Example&amp;quot;);&lt;br /&gt;
    // Insert the appropriate labels and check boxes&lt;br /&gt;
    setLayout(new GridLayout(0, 1)); // just make as many rows as we need&lt;br /&gt;
    add(nameLabel);&lt;br /&gt;
    add(descriptionLabel);&lt;br /&gt;
    add(tableLabel);&lt;br /&gt;
    add(new JSeparator());&lt;br /&gt;
    add(actionCheckBox);&lt;br /&gt;
    add(componentCheckBox);&lt;br /&gt;
    add(editableTextCheckBox);&lt;br /&gt;
    add(hypertextCheckBox);&lt;br /&gt;
    add(iconCheckBox);&lt;br /&gt;
    add(selectionCheckBox);&lt;br /&gt;
    add(tableCheckBox);&lt;br /&gt;
    add(textCheckBox);&lt;br /&gt;
    add(valueCheckBox);&lt;br /&gt;
    add(classLabel);&lt;br /&gt;
    add(parentLabel);&lt;br /&gt;
    add(relationLabel);&lt;br /&gt;
    add(performAction);&lt;br /&gt;
    setBorder(new TitledBorder(&amp;quot;Accessible Component&amp;quot;));&lt;br /&gt;
    performAction.addActionListener(this);&lt;br /&gt;
    frame.getContentPane().add(this, BorderLayout.CENTER);&lt;br /&gt;
    frame.setBounds(100, 100, 500, 600);&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
    //  Check to see if the GUI subsystem is initialized&lt;br /&gt;
    //  correctly. (This is needed in JDK 1.2 and higher).&lt;br /&gt;
    //  If it isn&amp;quot;t ready, then we have to wait.&lt;br /&gt;
    if (EventQueueMonitor.isGUIInitialized()) {&lt;br /&gt;
      createGUI();&lt;br /&gt;
    } else {&lt;br /&gt;
      EventQueueMonitor.addGUIInitializedListener(this);&lt;br /&gt;
    }&lt;br /&gt;
    performAction.grabFocus();&lt;br /&gt;
  }&lt;br /&gt;
  public void guiInitialized() {&lt;br /&gt;
    createGUI();&lt;br /&gt;
  }&lt;br /&gt;
  public void createGUI() {&lt;br /&gt;
    //  We want to track the mouse motions, so notify the&lt;br /&gt;
    //  Swing event monitor of this.&lt;br /&gt;
    SwingEventMonitor.addMouseMotionListener(this);&lt;br /&gt;
    //  Start a Timer object to measure how long the mouse stays&lt;br /&gt;
    //  over a particular area.&lt;br /&gt;
    timer = new Timer(500, this);&lt;br /&gt;
  }&lt;br /&gt;
  public void mouseMoved(MouseEvent e) {&lt;br /&gt;
    //  If the mouse moves, restart the timer.&lt;br /&gt;
    timer.restart();&lt;br /&gt;
  }&lt;br /&gt;
  public void mouseDragged(MouseEvent e) {&lt;br /&gt;
    //  If the mouse is dragged, restart the timer.&lt;br /&gt;
    timer.restart();&lt;br /&gt;
  }&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    //Find the component currently under the mouse.&lt;br /&gt;
    Point currentPosition = EventQueueMonitor.getCurrentMousePosition();&lt;br /&gt;
    Accessible comp = EventQueueMonitor.getAccessibleAt(currentPosition);&lt;br /&gt;
    //If the user pressed the button, and the component&lt;br /&gt;
    //has an accessible action, then execute it.&lt;br /&gt;
    if (e.getActionCommand() == &amp;quot;Perform Action&amp;quot;) {&lt;br /&gt;
      AccessibleContext context = comp.getAccessibleContext();&lt;br /&gt;
      AccessibleAction action = context.getAccessibleAction();&lt;br /&gt;
      if (action != null)&lt;br /&gt;
        action.doAccessibleAction(0);&lt;br /&gt;
      else&lt;br /&gt;
        System.out.println(&amp;quot;No accessible action present!&amp;quot;);&lt;br /&gt;
      return;&lt;br /&gt;
    }&lt;br /&gt;
    //  Otherwise, the timer has fired. Stop it and update the window.&lt;br /&gt;
    timer.stop();&lt;br /&gt;
    updateWindow(comp);&lt;br /&gt;
  }&lt;br /&gt;
  private void updateWindow(Accessible component) {&lt;br /&gt;
    if (component == null) {&lt;br /&gt;
      return;&lt;br /&gt;
    }&lt;br /&gt;
    // Reset the check boxes&lt;br /&gt;
    actionCheckBox.setSelected(false);&lt;br /&gt;
    selectionCheckBox.setSelected(false);&lt;br /&gt;
    textCheckBox.setSelected(false);&lt;br /&gt;
    componentCheckBox.setSelected(false);&lt;br /&gt;
    valueCheckBox.setSelected(false);&lt;br /&gt;
    hypertextCheckBox.setSelected(false);&lt;br /&gt;
    iconCheckBox.setSelected(false);&lt;br /&gt;
    tableCheckBox.setSelected(false);&lt;br /&gt;
    editableTextCheckBox.setSelected(false);&lt;br /&gt;
    // Get the accessibile context of the component in question&lt;br /&gt;
    AccessibleContext context = component.getAccessibleContext();&lt;br /&gt;
    AccessibleRelationSet ars = context.getAccessibleRelationSet();&lt;br /&gt;
    nameLabel.setText(&amp;quot;Name: &amp;quot; + context.getAccessibleName());&lt;br /&gt;
    descriptionLabel.setText(&amp;quot;Desc: &amp;quot; + context.getAccessibleDescription());&lt;br /&gt;
    relationLabel.setText(&amp;quot;Relation: &amp;quot; + ars);&lt;br /&gt;
    // Check the context for each of the accessibility types&lt;br /&gt;
    if (context.getAccessibleAction() != null)&lt;br /&gt;
      actionCheckBox.setSelected(true);&lt;br /&gt;
    if (context.getAccessibleSelection() != null)&lt;br /&gt;
      selectionCheckBox.setSelected(true);&lt;br /&gt;
    if (context.getAccessibleText() != null) {&lt;br /&gt;
      textCheckBox.setSelected(true);&lt;br /&gt;
      if (context.getAccessibleText() instanceof AccessibleHypertext)&lt;br /&gt;
        hypertextCheckBox.setSelected(true);&lt;br /&gt;
    }&lt;br /&gt;
    if (context.getAccessibleComponent() != null) {&lt;br /&gt;
      componentCheckBox.setSelected(true);&lt;br /&gt;
      classLabel.setText(&amp;quot;Class: &amp;quot; + context.getAccessibleComponent());&lt;br /&gt;
      parentLabel.setText(&amp;quot;Parent: &amp;quot; + context.getAccessibleParent());&lt;br /&gt;
    }&lt;br /&gt;
    if (context.getAccessibleValue() != null)&lt;br /&gt;
      valueCheckBox.setSelected(true);&lt;br /&gt;
    if (context.getAccessibleIcon() != null)&lt;br /&gt;
      iconCheckBox.setSelected(true);&lt;br /&gt;
    if ((context.getAccessibleTable() != null)&lt;br /&gt;
        || (context.getAccessibleParent() instanceof JTable)) {&lt;br /&gt;
      tableCheckBox.setSelected(true);&lt;br /&gt;
      tableLabel.setText(&amp;quot;Table Desc: &amp;quot;&lt;br /&gt;
          + context.getAccessibleParent().getAccessibleContext()&lt;br /&gt;
              .getAccessibleDescription());&lt;br /&gt;
    } else {&lt;br /&gt;
      tableLabel.setText(&amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    // On 1.4+ systems, you can check for editable text with these two&lt;br /&gt;
    // lines.&lt;br /&gt;
    // Note that because of the 1.4 restriction, these lines will not&lt;br /&gt;
    // compile&lt;br /&gt;
    // on a Mac system as of the time of this writing. You can comment out&lt;br /&gt;
    // these lines and still compile/run the example, though.&lt;br /&gt;
    //if (context.getAccessibleEditableText() != null)&lt;br /&gt;
    //  editableTextCheckBox.setSelected(true);&lt;br /&gt;
    repaint();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== An example of getting the Accessible information from a Button object ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java Swing, 2nd Edition&lt;br /&gt;
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole&lt;br /&gt;
ISBN: 0-596-00408-7&lt;br /&gt;
Publisher: O&amp;quot;Reilly &lt;br /&gt;
*/&lt;br /&gt;
// ActionExampleButton.java&lt;br /&gt;
//An example of getting the Accessible information from a Button object.&lt;br /&gt;
//(You could see this information by attaching an AssistiveExample object&lt;br /&gt;
//to the button. See BigExample.java for an example of that attachment.)&lt;br /&gt;
//&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Button;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.util.Locale;&lt;br /&gt;
import javax.accessibility.Accessible;&lt;br /&gt;
import javax.accessibility.AccessibleAction;&lt;br /&gt;
import javax.accessibility.AccessibleContext;&lt;br /&gt;
import javax.accessibility.AccessibleRole;&lt;br /&gt;
import javax.accessibility.AccessibleStateSet;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.SwingUtilities;&lt;br /&gt;
public class ActionExample extends Button implements ActionListener, Accessible {&lt;br /&gt;
  public ActionExample() {&lt;br /&gt;
    super(&amp;quot;Press this Button&amp;quot;);&lt;br /&gt;
    addActionListener(this);&lt;br /&gt;
  }&lt;br /&gt;
  public AccessibleContext getAccessibleContext() {&lt;br /&gt;
    return (new ActionAccessibleContext());&lt;br /&gt;
  }&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    System.out.println(&amp;quot;The button was pressed!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void processActionEvent(ActionEvent e) {&lt;br /&gt;
    super.processActionEvent(e);&lt;br /&gt;
  }&lt;br /&gt;
  // This class contains the accessible context for the component. Many&lt;br /&gt;
  // abstract methods simply call the SwingUtilities class to get the job&lt;br /&gt;
  // done; this is advised if you can get away with it. Otherwise, see the&lt;br /&gt;
  // source code for SwingUtilities.&lt;br /&gt;
  class ActionAccessibleContext extends AccessibleContext {&lt;br /&gt;
    public ActionAccessibleContext() {&lt;br /&gt;
      super();&lt;br /&gt;
      setAccessibleName(&amp;quot;Button&amp;quot;);&lt;br /&gt;
      setAccessibleDescription(&amp;quot;Press the Button&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public AccessibleRole getAccessibleRole() {&lt;br /&gt;
      // Fill in whatever role you want here&lt;br /&gt;
      return (AccessibleRole.AWT_COMPONENT);&lt;br /&gt;
    }&lt;br /&gt;
    public AccessibleStateSet getAccessibleStateSet() {&lt;br /&gt;
      return SwingUtilities.getAccessibleStateSet(ActionExample.this);&lt;br /&gt;
    }&lt;br /&gt;
    public int getAccessibleIndexInParent() {&lt;br /&gt;
      return SwingUtilities&lt;br /&gt;
          .getAccessibleIndexInParent(ActionExample.this);&lt;br /&gt;
    }&lt;br /&gt;
    public int getAccessibleChildrenCount() {&lt;br /&gt;
      return SwingUtilities&lt;br /&gt;
          .getAccessibleChildrenCount(ActionExample.this);&lt;br /&gt;
    }&lt;br /&gt;
    public Accessible getAccessibleChild(int i) {&lt;br /&gt;
      return SwingUtilities.getAccessibleChild(ActionExample.this, i);&lt;br /&gt;
    }&lt;br /&gt;
    public Locale getLocale() {&lt;br /&gt;
      //  Ask the component what its locale is&lt;br /&gt;
      return ActionExample.this.getLocale();&lt;br /&gt;
    }&lt;br /&gt;
    public AccessibleAction getAccessibleAction() {&lt;br /&gt;
      return new AccessAction();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // This class implements the AccessibleAction interface. Essentially, there&lt;br /&gt;
  // is only one action that is the equivalent of pushing the button.&lt;br /&gt;
  class AccessAction implements AccessibleAction {&lt;br /&gt;
    final int NUMBER_OF_ACTIONS = 1;&lt;br /&gt;
    final String DESCRIPTION = &amp;quot;Presses the button&amp;quot;;&lt;br /&gt;
    public int getAccessibleActionCount() {&lt;br /&gt;
      return NUMBER_OF_ACTIONS;&lt;br /&gt;
    }&lt;br /&gt;
    public String getAccessibleActionDescription(int i) {&lt;br /&gt;
      if (i == 0)&lt;br /&gt;
        return (DESCRIPTION);&lt;br /&gt;
      else&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    public boolean doAccessibleAction(int i) {&lt;br /&gt;
      if (i == 0) {&lt;br /&gt;
        // Simulate pressing a button&lt;br /&gt;
        ActionExample.this.processActionEvent(new ActionEvent(this,&lt;br /&gt;
            ActionEvent.ACTION_PERFORMED, ActionExample.this&lt;br /&gt;
                .getActionCommand()));&lt;br /&gt;
        return true;&lt;br /&gt;
      } else&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String s[]) {&lt;br /&gt;
    ActionExample example = new ActionExample();&lt;br /&gt;
    JFrame frame = new JFrame(&amp;quot;AccessibleAction Example&amp;quot;);&lt;br /&gt;
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    frame.getContentPane().add(example, BorderLayout.CENTER);&lt;br /&gt;
    frame.setSize(100, 100);&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Associating a Label with a Component ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    JTextField component = new JTextField();&lt;br /&gt;
    JLabel label = new JLabel(&amp;quot;Name:&amp;quot;);&lt;br /&gt;
    label.setDisplayedMnemonic(&amp;quot;N&amp;quot;);&lt;br /&gt;
    label.setLabelFor(component);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Has Displayed Name ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import javax.swing.AbstractButton;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.text.JTextComponent;&lt;br /&gt;
&lt;br /&gt;
public class Util {&lt;br /&gt;
  public static boolean hasDisplayedName(Class componentClass) {&lt;br /&gt;
    return ((AbstractButton.class.isAssignableFrom(componentClass))&lt;br /&gt;
            || (JLabel.class.isAssignableFrom(componentClass))&lt;br /&gt;
            || (JTextComponent.class.isAssignableFrom(componentClass))&lt;br /&gt;
    );&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== implement Accessible to make your object accessible ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.awt.IllegalComponentStateException;&lt;br /&gt;
import java.util.Locale;&lt;br /&gt;
import javax.accessibility.Accessible;&lt;br /&gt;
import javax.accessibility.AccessibleContext;&lt;br /&gt;
import javax.accessibility.AccessibleRole;&lt;br /&gt;
import javax.accessibility.AccessibleStateSet;&lt;br /&gt;
public class Main implements Accessible {&lt;br /&gt;
  public AccessibleContext getAccessibleContext() {&lt;br /&gt;
    return new AccessibleContext() {&lt;br /&gt;
      @Override&lt;br /&gt;
      public AccessibleRole getAccessibleRole() {&lt;br /&gt;
        return null;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public AccessibleStateSet getAccessibleStateSet() {&lt;br /&gt;
        return null;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public int getAccessibleIndexInParent() {&lt;br /&gt;
        return 0;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public int getAccessibleChildrenCount() {&lt;br /&gt;
        return 0;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public Accessible getAccessibleChild(int i) {&lt;br /&gt;
        return null;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public Locale getLocale() throws IllegalComponentStateException {&lt;br /&gt;
        return null;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting a Description for Image Icons ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    ImageIcon icon = new ImageIcon(&amp;quot;image.gif&amp;quot;);&lt;br /&gt;
    icon.setDescription(&amp;quot;Description of Image&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting a Keyboard Accelerator for a Menu Item ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.awt.event.KeyEvent;&lt;br /&gt;
import javax.swing.JMenuItem;&lt;br /&gt;
import javax.swing.KeyStroke;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    JMenuItem item = new JMenuItem(&amp;quot;Item&amp;quot;);&lt;br /&gt;
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.SHIFT_MASK));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting a Mnemonic for a Menu for Accessible ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import javax.swing.JMenu;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    JMenu menu = new JMenu(&amp;quot;Menu&amp;quot;);&lt;br /&gt;
    menu.setMnemonic(&amp;quot;M&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting a Mnemonic for Buttons for Accessible ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    JButton button = new JButton(&amp;quot;Button&amp;quot;);&lt;br /&gt;
    button.setMnemonic(&amp;quot;B&amp;quot;);&lt;br /&gt;
    JCheckBox checkBox = new JCheckBox(&amp;quot;CheckBox&amp;quot;);&lt;br /&gt;
    checkBox.setMnemonic(&amp;quot;C&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting an Accessible Name for an Image Button ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
  JButton button = new JButton(new ImageIcon(&amp;quot;image.gif&amp;quot;));&lt;br /&gt;
    button.setToolTipText(&amp;quot;Button Name&amp;quot;);&lt;br /&gt;
    button.getAccessibleContext().setAccessibleName(&amp;quot;Button Name&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>