Example usage for javax.swing JComboBox getComponents

List of usage examples for javax.swing JComboBox getComponents

Introduction

In this page you can find the example usage for javax.swing JComboBox getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:Main.java

public Main() {

    someComboBox.setFont(new Font("Serif", Font.BOLD, 16));
    someComboBox.setEditable(true);/*  w w  w .ja  v  a2s. c  o  m*/
    someComboBox.getEditor().getEditorComponent().setBackground(Color.YELLOW);
    ((JTextField) someComboBox.getEditor().getEditorComponent()).setBackground(Color.YELLOW);

    JTextField text = ((JTextField) editableComboBox.getEditor().getEditorComponent());
    text.setBackground(Color.YELLOW);
    JComboBox coloredArrowsCombo = editableComboBox;
    Component[] comp = coloredArrowsCombo.getComponents();
    for (int i = 0; i < comp.length; i++) {
        if (comp[i] instanceof MetalComboBoxButton) {
            MetalComboBoxButton coloredArrowsButton = (MetalComboBoxButton) comp[i];
            coloredArrowsButton.setBackground(null);
            break;
        }
    }

    non_EditableComboBox.setFont(new Font("Serif", Font.BOLD, 16));

    frame = new JFrame();
    frame.setLayout(new GridLayout(0, 1, 10, 10));
    frame.add(someComboBox);
    frame.add(editableComboBox);
    frame.add(non_EditableComboBox);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(100, 100);
    frame.pack();
    frame.setVisible(true);
}