A high contrast mode supports people with
low vision. On Microsoft Windows systems, high contrast mode is
available from the Control Panel; in the Ease of Access Center in
Windows 7 and equivalent facilities in other versions of Windows.
To detect high contrast mode in Java™
, use the IlvSwingUtil.isHighContrastMode utility. The
high contrast mode affects all standard Swing GUI elements (JPanel, JButton,
and so on). Custom Swing elements might need special code to adapt
to high contrast mode.
You can set larger fonts for labels and brighter colors for graphic
objects in the JViews
Framework, but it does not provide a one-step API to toggle the
high contrast mode on. To support a high contrast mode in your
application, set the view background appropriately and iterate over
all objects to set their colors, fonts, and sizes, as illustrated
in the following code example:
void setHighContrast(IlvManager manager, IlvManagerView mgrview, boolean on) { // set the selection handle color to light or dark depending on the mode manager.deSelectAll(true); IlvHandlesSelection.defaultHandleColor = on ? new Color(180,180,255) : Color.black; //the view background mgrview.setBackground(on ? Color.black : Color.white); Font normalContrastFont = new Font("dialog", "bold", 12); Font highContrastFont = new Font("dialog", "bold", 16); IlvGraphicEnumeration e = grapher.getObjects(true); while (e.hasMoreElements()) { IlvGraphic g = e.nextElement(); if (g instanceof IlvText) { IlvText text = (IlvText)g; text.setForeground(on ? Color.white : Color.black); text.setFont(on ? highContrastFont : normalContrastFont); } else if (g instanceof ...) { ... other adaptions for other graphic objects ... } } mgrview.repaint(); }
You can find a sample that illustrates the accessibility features
of the JViews Framework
in <installdir>/jviews-frameworkxx/samples/accessibility.