Example usage for javax.swing JComboBox setUI

List of usage examples for javax.swing JComboBox setUI

Introduction

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

Prototype

@BeanProperty(hidden = true, visualUpdate = true, description = "The UI object that implements the Component's LookAndFeel.")
public void setUI(ComboBoxUI ui) 

Source Link

Document

Sets the L&F object that renders this component.

Usage

From source file:PopupComboSample.java

public static void main(String args[]) {
    String labels[] = { "A", "B", "C", "D", "E", "F", "G" };
    JFrame frame = new JFrame("Popup JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComboBox comboBox = new JComboBox(labels);
    comboBox.setUI((ComboBoxUI) MyComboBoxUI.createUI(comboBox));
    frame.add(comboBox, BorderLayout.NORTH);

    frame.setSize(300, 200);/*from  w w  w.  ja  va  2  s.  co  m*/
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    final String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Popup JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComboBox comboBox = new JComboBox(labels);
    comboBox.setUI((ComboBoxUI) MyComboBoxUI.createUI(comboBox));
    frame.add(comboBox, BorderLayout.NORTH);

    frame.setSize(300, 200);/*from   w  w  w  .j  ava  2 s . c o m*/
    frame.setVisible(true);

}

From source file:MyComboBoxUI.java

public static void main(String args[]) {
    String labels[] = { "A", "B", "C", "D" };
    JFrame frame = new JFrame("Popup JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComboBox comboBox = new JComboBox(labels);
    comboBox.setUI((ComboBoxUI) MyComboBoxUI.createUI(comboBox));
    frame.add(comboBox, BorderLayout.NORTH);

    JComboBox comboBox2 = new JComboBox(labels);
    frame.add(comboBox2, BorderLayout.SOUTH);

    frame.setSize(300, 100);//from www. j  a va  2 s . c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static JComboBox generateComboBoxFor(Object... objs) {
    Container c = search(objs, Container.class);
    ComboBoxModel model = null;//  ww w .  j a  v  a  2  s  . com
    Vector items = null;
    Object[] itms = null;
    Border border = search(objs, Border.class);
    Color color = search(objs, Color.class);
    ComboBoxUI ui = search(objs, ComboBoxUI.class);
    JComboBox combo = (model = search(objs, ComboBoxModel.class)) == null
            ? (items = search(objs, Vector.class)) == null ? new JComboBox(itms = search(objs, Object[].class))
                    : new JComboBox(items)
            : new JComboBox(model);
    if (border != null)
        combo.setBorder(border);
    if (ui != null)
        combo.setUI(ui);
    if (color != null)
        combo.setBackground(color);
    addJContainerListeners(combo, objs);
    addToContainer(c, combo);
    return combo;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static <T> JComboBox<T> createComboBox(T[] values, JFormattedTextField textField,
        DocumentListener... docListeners) {
    JComboBox<T> cbox = new JComboBox<T>(values);
    cbox.setUI(new IntelComboBoxUI());
    FormattedComboBoxEditor editor = new FormattedComboBoxEditor(textField);
    cbox.setEditable(true);//ww  w  .  ja v a2 s .  c o m
    cbox.setEditor(editor);

    // Get the text editor for this combo box
    final JTextComponent tc = (JTextComponent) cbox.getEditor().getEditorComponent();

    // Initialize the document listeners
    for (DocumentListener docListener : docListeners) {
        tc.getDocument().addDocumentListener(docListener);
    }
    return cbox;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JComboBox<String> createComboBox(String[] strArray, DocumentListener... docListeners) {

    JComboBox<String> cbox = new JComboBox<String>(strArray) {
        private static final long serialVersionUID = -7465791917624978560L;

        @Override/* ww w  . j a v a2s. co  m*/
        public String toString() {
            return "JComboBox@" + StringUtils.intHexString(hashCode());
        }
    };
    cbox.setUI(new IntelComboBoxUI());

    // Get the text editor for this combo box
    JTextComponent tc = (JTextComponent) cbox.getEditor().getEditorComponent();

    // Initialize the document listeners
    for (DocumentListener docListener : docListeners) {
        tc.getDocument().addDocumentListener(docListener);
    }
    return cbox;
}