Java Solaris Communities About Sun How to Buy United States Worldwide

Accessibility

Accessibility Resources Banner
Begin Product Tab Sub Links At a Glance Articles Active Sub Link Documentation

Java Accessibility Quick Tips - Ensuring and Verifying Basic Application Accessibility

The following are quick tips on how to make Java applications accessible. A full set of guidelines, which also contain code snippets as well as information on how to build custom components, are available in IBM's Guidelines for Writing Accessible Applications Using 100% Pure Java and The Java Tutorial. A condensed version of these two can be found in Developing Accessible JFC Applications.

  • Use the JFC(Swing) UI components to build applications - The built-in accessibility support provided by the Java 2 Platform makes it possible to produce access-friendly applications in an efficient and timely manner.

  • Make sure an AccessibleName is set on all components in an application - While an AccessibleName is always required, it is not always necessary for the developer to explicitly set this property. Components such as labels, buttons, and menu items which generally are named will have the AccessibleName property automatically set to the text they contain. In situations where a label names another component, e.g. a label naming a text field, AccessibleName inherits what is set in the LabelFor property (see the tip regarding LabelFor below). If the previous suggestions do not provide an object with a sufficient name, as with a .gif file for example, the value of the AccessibleName property can be programmatically set to any string. Setting the accessible name allows assistive technologies to provide the user with the name of the component that has the input focus. This is always required, even if a tooltip or an accessible description is set on the component.

  • Make sure an AccessibleDescription is set on all components whose context is not obvious from their names - If the purpose of a component is obvious from its name, this step can be skipped. If more information is required, consider adding a tooltip to the component, since the AccessibleDescription will default to the contents of the tooltip. If a tooltip is not appropriate or if its contents are insufficient for a user with a disability, the value of the AccessibleDescription property should be set. Setting this accessible description allows assistive technologies to provide more detailed information about a component, usually in response to a user's request.

  • Set the LabelFor properties on applicable components - Setting this property creates a linkage between labels and the items they are labeling. This is very important in the case of a JLabel that appears in front of a blank editable text field, where the label is telling the user what the editable text field is. Linking such items allows assistive technologies to discover and identify the editable textfield for the user.

  • Layout interactive components in a logical tab navigation order - Many users with disabilities are unable to use a mouse, and rely completely on the keyboard to access applications. A logical order makes it easier for keyboard-only users to track their position in the interface. Whenever possible, adopt a navigation flow similar to the user's locale. For example, English has a left to right, top to bottom flow structure.

  • Assign mnemonics to all of the essential functions of an application - When a user relies completely on the keyboard to drive a program, quick and easy access to important parts of the interface (independent of where the user is in the tab order) is needed. Mnemonics allow the user to navigate directly to interactive components. This bypasses the need to navigate across components that are not of interest.

  • When building Custom Components, keep in mind that the JComponent class, itself, does not implement the Accessible interface - Therefore, instances of its direct subclasses are not accessible. If a custom component inherits directly from JComponent, it must explicitly implement the Accessible interface. JComponent does have an accessible context (called AccessibleJComponent), that implements the AccessibleComponent interface and provides a minimal amount of accessible information. An accessible context for custom components can be provided by creating a subclass of AccessibleJComponent and overriding important methods.

  • Avoid hard coding color and font properties - It is important to respect users' needs to customize these settings, as they may be critical in their ability to read and understand what is on the screen.

  • Use the Java Accessibility Helper to determine how access friendly your program is - The Java Accessibility Helper aids Java software developers in making their JFC-based programs accessible to persons with disabilities. The Helper generates a report that includes a prioritized list of problems and potential problems with the application being tested. For example, the Helper verifies that all input fields in an application can be reached using only the keyboard.

A Note Regarding Internationalization

A software developer following these tips will find that the requirements presented here behave synergistically with those of internationalization. By allowing the accessibility data to be pulled from tooltips and labels wherever possible, localization efforts will automatically extend to the accessibility properties. In those few cases where accessibility properties are set directly and unique strings are added to an application, the new strings should be stored in the application's properties bundle. When the bundle is localized, the accessibility values will be included in the effort.

Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright 1994-2008 Sun Microsystems, Inc.