Example usage for javax.accessibility AccessibleContext ACCESSIBLE_STATE_PROPERTY

List of usage examples for javax.accessibility AccessibleContext ACCESSIBLE_STATE_PROPERTY

Introduction

In this page you can find the example usage for javax.accessibility AccessibleContext ACCESSIBLE_STATE_PROPERTY.

Prototype

String ACCESSIBLE_STATE_PROPERTY

To view the source code for javax.accessibility AccessibleContext ACCESSIBLE_STATE_PROPERTY.

Click Source Link

Document

Constant used to determine when the accessibleStateSet property has changed.

Usage

From source file:com.konifar.material_icon_generator.FilterComboBox.java

private void initListener() {
    final JTextField textfield = (JTextField) this.getEditor().getEditorComponent();
    textfield.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            switch (event.getKeyCode()) {
            case KeyEvent.VK_ENTER:
            case KeyEvent.VK_ESCAPE:
                requestFocus(false);//w w  w  . ja  v a2  s.c o m
                break;
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
                break;
            default:
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        filter(textfield.getText());
                    }
                });
            }
        }
    });

    getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName())
                    && AccessibleState.FOCUSED.equals(event.getNewValue())
                    && getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) {
                ComboPopup popup = (ComboPopup) getAccessibleContext().getAccessibleChild(0);
                JList list = popup.getList();

                if (list.getSelectedValue() != null) {
                    setSelectedItem(String.valueOf(list.getSelectedValue()));
                }
            }
        }
    });
}

From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java

private void initDpComboBox() {
    comboBoxDp.addActionListener(new ActionListener() {
        @Override//  ww  w. j  a  va 2s. com
        public void actionPerformed(ActionEvent event) {
            model.setDpAndFileName((String) comboBoxDp.getSelectedItem());
            textFieldFileName.setText(model.getFileName());
            showIconPreview();
        }
    });

    comboBoxDp.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName())
                    && AccessibleState.FOCUSED.equals(event.getNewValue())
                    && comboBoxDp.getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) {
                ComboPopup popup = (ComboPopup) comboBoxDp.getAccessibleContext().getAccessibleChild(0);
                JList list = popup.getList();
                comboBoxDp.setSelectedItem(String.valueOf(list.getSelectedValue()));
            }
        }
    });
}

From source file:AccessibleScrollDemo.java

public void setIsMetric(boolean isMetric) {
    if (accessibleContext != null && this.isMetric != isMetric) {
        if (isMetric) {
            accessibleContext.firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
                    AccessibleRulerState.INCHES, AccessibleRulerState.CENTIMETERS);
        } else {//from ww  w .j  ava 2s .com
            accessibleContext.firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
                    AccessibleRulerState.CENTIMETERS, AccessibleRulerState.INCHES);
        }
    }
    this.isMetric = isMetric;
    setIncrementAndUnits();
    repaint();
}

From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java

private void initColorComboBox() {
    comboBoxColor.addActionListener(new ActionListener() {
        @Override//from  w w  w.ja  va 2 s  .co  m
        public void actionPerformed(ActionEvent event) {
            model.setColorAndFileName((String) comboBoxColor.getSelectedItem());
            textFieldFileName.setText(model.getFileName());
            showIconPreview();
        }
    });

    comboBoxColor.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName())
                    && AccessibleState.FOCUSED.equals(event.getNewValue())
                    && comboBoxColor.getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) {
                ComboPopup popup = (ComboPopup) comboBoxColor.getAccessibleContext().getAccessibleChild(0);
                JList list = popup.getList();
                comboBoxColor.setSelectedItem(String.valueOf(list.getSelectedValue()));
            }
        }
    });
}