Search in sources :

Example 6 with BasicComboBoxUI

use of javax.swing.plaf.basic.BasicComboBoxUI in project java-swing-tips by aterai.

the class MainPanel method makeComboBox.

private static JComboBox<String> makeComboBox() {
    JComboBox<String> combo = new JComboBox<String>(new String[] { "Name 0", "Name 1", "Name 2" }) {

        @Override
        public void updateUI() {
            super.updateUI();
            setBorder(BorderFactory.createEmptyBorder());
            setUI(new BasicComboBoxUI() {

                @Override
                protected JButton createArrowButton() {
                    JButton button = super.createArrowButton();
                    button.setContentAreaFilled(false);
                    button.setBorder(BorderFactory.createEmptyBorder());
                    return button;
                }
            });
        //                 JTextField editor = (JTextField) getEditor().getEditorComponent();
        //                 editor.setBorder(BorderFactory.createEmptyBorder());
        //                 editor.setOpaque(true);
        //                 editor.setEditable(false);
        }
    };
    //combo.setEditable(true);
    return combo;
}
Also used : BasicComboBoxUI(javax.swing.plaf.basic.BasicComboBoxUI)

Aggregations

BasicComboBoxUI (javax.swing.plaf.basic.BasicComboBoxUI)6 ComboBoxUI (javax.swing.plaf.ComboBoxUI)2 ComboPopup (javax.swing.plaf.basic.ComboPopup)2 Nullable (org.jetbrains.annotations.Nullable)2 Field (java.lang.reflect.Field)1