Example usage for javax.swing.plaf.metal MetalComboBoxButton setBackground

List of usage examples for javax.swing.plaf.metal MetalComboBoxButton setBackground

Introduction

In this page you can find the example usage for javax.swing.plaf.metal MetalComboBoxButton setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:Main.java

public Main() {

    someComboBox.setFont(new Font("Serif", Font.BOLD, 16));
    someComboBox.setEditable(true);//ww  w . j av  a2 s.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);
}