4631925: JColor Chooser is not fully accessible
authorjviswana
Tue, 04 Dec 2012 17:17:45 +0400
changeset 14658 67661687f722
parent 14657 35542ae38486
child 14659 cda39b3e7f15
4631925: JColor Chooser is not fully accessible Reviewed-by: alexsch
jdk/src/share/classes/javax/swing/JColorChooser.java
jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java
jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java
jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
--- a/jdk/src/share/classes/javax/swing/JColorChooser.java	Tue Dec 04 16:42:19 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/JColorChooser.java	Tue Dec 04 17:17:45 2012 +0400
@@ -182,6 +182,7 @@
             dialog = new ColorChooserDialog((Dialog)window, title, modal, c, chooserPane,
                                             okListener, cancelListener);
         }
+        dialog.getAccessibleContext().setAccessibleDescription(title);
         return dialog;
     }
 
@@ -647,6 +648,7 @@
         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 @@
         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 @@
         buttonPane.add(cancelButton);
 
         JButton resetButton = new JButton(resetString);
+        resetButton.getAccessibleContext().setAccessibleDescription(resetString);
         resetButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                reset();
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java	Tue Dec 04 16:42:19 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java	Tue Dec 04 17:17:45 2012 +0400
@@ -135,6 +135,7 @@
         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);
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java	Tue Dec 04 16:42:19 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java	Tue Dec 04 17:17:45 2012 +0400
@@ -37,6 +37,7 @@
 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 @@
         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);
         }
     }
 
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java	Tue Dec 04 16:42:19 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java	Tue Dec 04 17:17:45 2012 +0400
@@ -94,6 +94,7 @@
         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);