USEPA / emf

Emissions Modeling Framework (EMF)
6 stars 3 forks source link

screen readers not reading contents of Status window messages table #72

Closed cseppan closed 2 years ago

cseppan commented 2 years ago

The Status Window table uses a custom TableCellRenderer built on JTextArea (MultiLineCellRenderer). The Swing default cell renderer (DefaultTableCellRenderer) uses a JLabel. With the default renderer, screen readers automatically read the contents of the cell, the row and column numbers, and the header name. For cell renderers based on JTextArea, calling setAccessibleName() with the cell contents lets the screen readers access the contents, but it doesn't tie in to the row and column information. It's not clear what would be needed to make a JTextArea behave like a JLabel for accessibility when used in a table cell renderer.

The common advice for multi-line labels is to use a JLabel with HTML content. Switching the Status Window to use the default cell renderer and wrapping the content in HTML tags works as expected with the screen readers. One note about this approach: if the status message is copied and pasted from the Status Window, it will have HTML tags included in the text, e.g. <html>Started exporting test_inv to /usr/local/tomcat/webapps/exports/admin/test_inv_07mar2021_v0</html>

cseppan commented 2 years ago

Commit e12360832af9cab9661fc852cfc287fa93e06193 updates MultiLineCellRenderer to extend DefaultTableCellRenderer. This takes advantage of the display optimizations built in to the default cell renderer. A custom class is still needed to set the label positioning within the cell and to work with the MultiLineTable class. In StatusTableModel, the message field of the Status object gets wrapped in <html></html> tags so the message will wrap to multiple lines instead of being truncated.