Example usage for javax.swing.plaf.basic ComboPopup getList

List of usage examples for javax.swing.plaf.basic ComboPopup getList

Introduction

In this page you can find the example usage for javax.swing.plaf.basic ComboPopup getList.

Prototype

public JList<Object> getList();

Source Link

Document

Returns the list that is being used to draw the items in the combo box.

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 ww  .ja v  a 2s  .  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//from  w ww  .  ja  va 2  s  .c om
        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:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java

private void initColorComboBox() {
    comboBoxColor.addActionListener(new ActionListener() {
        @Override//from w  ww  .  ja  v a 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()));
            }
        }
    });
}