Making Java programs accessible for visually impaired users


R

Ross

I'm rather confused about the very varied information on the web about
how to make Swing applications accessible for visually impaired users.
I've found this page which describes it as being easy and
straightforward, and gives some examples. http://www.erigena.com/resources/articles/accessible-java/

I've extended that program to produce a new example, see below. This
is my first attempt at even a one-pager in terms of accessibility.

The program I would like to make accessible includes a small number of
custom GUI widgets, so I'd need to implement various interfaces. But,
I've found this as an example: http://www-03.ibm.com/able/guidelines/java/snsjavagcustom.html

Is there a current "best practice" or best choice of tools which could
be used to make a Java application accessible?




import java.awt.*;
import javax.swing.*;
import javax.accessibility.*;
import java.awt.event.*;

public class AccessTest extends JFrame
{
private JList content;

public AccessTest()
{
setLayout( new BorderLayout() );
JMenu file = new JMenu( "File" );
file.setMnemonic( 'F' );

AccessibleContext context = file.getAccessibleContext();
context.setAccessibleName( "File Menu" );
context.setAccessibleDescription( "Menu for loading and saving
files" );

JMenuItem quit = new JMenuItem( "Quit" );
quit.setMnemonic( 'Q' );
quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
Event.CTRL_MASK));

context = quit.getAccessibleContext();
context.setAccessibleName( "Quit" );
context.setAccessibleDescription( "Quit Option" );

file.add( quit );
quit.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent aent )
{
goQuit();
}
}
);

JMenuBar jmb = new JMenuBar();
context = jmb.getAccessibleContext();
context.setAccessibleName( "Menu Bar" );
context.setAccessibleDescription( "The main menu bar" );
setJMenuBar( jmb );

jmb.add( file );

DefaultListModel dlm = new DefaultListModel();
content = new JList();

for ( int index = 0; index < 100; index++ )
{
dlm.addElement( "Item Number " + (index+1) );
}

content.setModel( dlm );

context = content.getAccessibleContext();
context.setAccessibleName( "Content" );
context.setAccessibleDescription( "List of options to choose
from" );

add( new JScrollPane( content ), BorderLayout.CENTER );

JPanel bottomPanel = new JPanel( new FlowLayout() );
context = content.getAccessibleContext();
context.setAccessibleName( "Items List" );
context.setAccessibleDescription( "Bottom panel with selection
buttons" );

JButton delete = new JButton( "Delete" );
delete.setMnemonic( 'D' );

delete.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent aent )
{
goDelete();
}
}
);

bottomPanel.add( delete );

JButton create = new JButton( "Create" );
create.setMnemonic( 'C' );
create.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent aent )
{
goCreate();
}
}
);

bottomPanel.add( create );

add( bottomPanel, BorderLayout.SOUTH );

setBounds( 200, 200, 200, 200 );
setTitle( "Test frame for accessibility" );

context = getAccessibleContext();
context.setAccessibleName( "Test Frame" );
context.setAccessibleDescription( "Test frame for some basic
experiments with the Java accessibility framework" );

addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent went )
{
goQuit();
}
}
);
}

private void goQuit()
{
System.exit( 0 );
}

public static void main( String args[] )
{
AccessTest at = new AccessTest();
at.setVisible( true );
}

private void goDelete()
{
JOptionPane.showMessageDialog( this, "The delete option was
selected", "Delete Selected",
JOptionPane.INFORMATION_MESSAGE );
}

private void goCreate()
{
JOptionPane.showMessageDialog( this, "The create option was
selected", "Create Selected",
JOptionPane.INFORMATION_MESSAGE );
}
}
 
Ad

Advertisements

S

Stefan Ram

Ross said:
Is there a current "best practice" or best choice of tools which could
be used to make a Java application accessible?

Having several visually impaired test users? (Not after but during
development.)

(Sorry, I lack the »tool thinking«.)
 
Ad

Advertisements

R

Ross

  Having several visually impaired test users? (Not after but during
  development.)

  (Sorry, I lack the »tool thinking«.)

I am talking to two visually impaired people who are giving me
feedback and ideas.

So far it looks as if Java, even with the Java Access Bridge, is a bit
of a nightmare.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top