Skip to Page Content | Navigation for Module


Navigation for Module 10: Scripts/Java
Page 16 of 19

Labels and Tables in Java

Labels and setLabelFor

To ease navigation for individuals with disabilities, it is often necessary to express the relationship between a group of components. Labels are commonly associated with components such as Buttons and Textfields, simply describing the purpose of the component. In terms of accessibility, this may clarify the interface, possibly eliminating redundant information. In other words, if the assistive technology is aware that a label is associated with the component, it often skips reading one of the descriptions.

A label can associate itself with a component by calling it setLabelFor( ) method, passing it the component it wants to bind to.

Code example for calling setLabelFor() method:

import javax.swing.*;
import java.awt.*;
import javax.accessibility.*;
 
class SetLabel extends JFrame {
      JLabel label;
      JTextField tf;
 
      SetLabel( ) {
         this.getContentPane().setLayout (new GridLayout (1,2));
         label = new JLabel ("Description of Animal");
         label.getAccessibleContext().setAccessibleDescription ("Description of Animal");
         tf = new JTextField (10);
         tf.getAccessibleContext().setAccessibleDescription ("Type the description of the animal here");
         // Associate the label with the textfield
         label.setLabelFor (tf);
         this.getContentPane().add (label);
         this.getContentPane().add (tf);
         this.pack();
         this.setVisible(true);
      }
      public static void main (String args[]) {
         SetLabel sl =new SetLabel();
      }
 
}

Tables

Tables present unique navigation problems for users with disabilities - especially those with vision impairments. When traversing through large tables of data, it is often easy to lose the context with which the data is associated. Most screenreaders (devices or programs that give an audio description of what's on a computer screen) often relay column header information during navigation. For example, let us assume that in the table above the social security number for 'Bob White' has focus. If the user moves to the cell to the immediately right, then some screen readers will say 'Grade' before speaking the grade data. The point is that it is important to give brief, descriptive header information when constructing your table (see Image 7).


Image 7: Java Accessible Table Example

It is important to give table summary information, as well as caption information to your tables. These are usually read just before the data in the table is considered. To insert a caption and summary, you can use setAccessibleCaption( ), as well as setAccessibleSummary( ).

The next page will discuss double-buffering.

Top of Page arrow up
       Page 16


 
-- END OF PAGE