4631925: JColor Chooser is not fully accessible

Reviewed-by: alexsch
This commit is contained in:
Jayashree Viswanathan 2012-12-04 17:17:45 +04:00
parent 8841803399
commit ec15d0a1b0
4 changed files with 18 additions and 2 deletions

View File

@ -182,6 +182,7 @@ public class JColorChooser extends JComponent implements Accessible {
dialog = new ColorChooserDialog((Dialog)window, title, modal, c, chooserPane,
okListener, cancelListener);
}
dialog.getAccessibleContext().setAccessibleDescription(title);
return dialog;
}
@ -647,6 +648,7 @@ class ColorChooserDialog extends JDialog {
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton okButton = new JButton(okString);
getRootPane().setDefaultButton(okButton);
okButton.getAccessibleContext().setAccessibleDescription(okString);
okButton.setActionCommand("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -659,6 +661,7 @@ class ColorChooserDialog extends JDialog {
buttonPane.add(okButton);
cancelButton = new JButton(cancelString);
cancelButton.getAccessibleContext().setAccessibleDescription(cancelString);
// The following few lines are used to register esc to close the dialog
Action cancelKeyAction = new AbstractAction() {
@ -688,6 +691,7 @@ class ColorChooserDialog extends JDialog {
buttonPane.add(cancelButton);
JButton resetButton = new JButton(resetString);
resetButton.getAccessibleContext().setAccessibleDescription(resetString);
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
reset();

View File

@ -135,6 +135,7 @@ final class ColorChooserPanel extends AbstractColorChooserPanel implements Prope
String label = this.model.getText(this, "HexCode"); // NON-NLS: suffix
boolean visible = label != null;
this.text.setVisible(visible);
this.text.getAccessibleContext().setAccessibleDescription(label);
this.label.setVisible(visible);
if (visible) {
this.label.setText(label);

View File

@ -37,6 +37,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import javax.swing.JSpinner.DefaultEditor;
final class ColorPanel extends JPanel implements ActionListener {
@ -119,17 +120,26 @@ final class ColorPanel extends JPanel implements ActionListener {
int count = this.model.getCount();
this.spinners[4].setVisible(count > 4);
for (int i = 0; i < count; i++) {
String text = this.model.getLabel(this, i);
Object object = this.spinners[i].getLabel();
if (object instanceof JRadioButton) {
JRadioButton button = (JRadioButton) object;
button.setText(this.model.getLabel(this, i));
button.setText(text);
button.getAccessibleContext().setAccessibleDescription(text);
}
else if (object instanceof JLabel) {
JLabel label = (JLabel) object;
label.setText(this.model.getLabel(this, i));
label.setText(text);
}
this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
this.spinners[i].setValue(this.values[i]);
this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
editor.getTextField().getAccessibleContext().setAccessibleName(text);
this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
}
}

View File

@ -94,6 +94,7 @@ public class BasicColorChooserUI extends ColorChooserUI
tabbedPane = new JTabbedPane();
tabbedPane.setName("ColorChooser.tabPane");
tabbedPane.setInheritsPopupMenu(true);
tabbedPane.getAccessibleContext().setAccessibleDescription(tabbedPane.getName());
singlePanel = new JPanel(new CenterLayout());
singlePanel.setName("ColorChooser.panel");
singlePanel.setInheritsPopupMenu(true);