Search in sources :

Example 1 with BasicComboBoxRenderer

use of javax.swing.plaf.basic.BasicComboBoxRenderer in project FlatLaf by JFormDesigner.

the class TestFlatComponentSizes method applyCustomComboBoxRendererBorder.

@SuppressWarnings("unchecked")
private void applyCustomComboBoxRendererBorder(JComboBox<String> comboBox, Border border) {
    BasicComboBoxRenderer customRenderer = new BasicComboBoxRenderer();
    customRenderer.setBorder(border);
    comboBox.setRenderer(customRenderer);
}
Also used : BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer)

Example 2 with BasicComboBoxRenderer

use of javax.swing.plaf.basic.BasicComboBoxRenderer in project FlatLaf by JFormDesigner.

the class FlatCustomBordersTest method applySpecialComboBoxRenderers.

@SuppressWarnings("unchecked")
private void applySpecialComboBoxRenderers() {
    BasicComboBoxRenderer sharedRenderer = new BasicComboBoxRenderer();
    sharedRenderer.setBorder(new LineBorder(BLUE, UIScale.scale(2)));
    comboBox29.setRenderer(sharedRenderer);
    comboBox30.setRenderer(sharedRenderer);
    comboBox31.setRenderer(new ListCellRenderer<String>() {

        JLabel l1 = new JLabel();

        JLabel l2 = new JLabel();

        @Override
        public Component getListCellRendererComponent(JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel l = (index % 2 == 0) ? l1 : l2;
            l.setText((value != null) ? value.toString() : "");
            l.setBorder(new LineBorder((index % 2 == 0) ? GREEN : RED, UIScale.scale(2)));
            l.setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
            l.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
            l.setFont(list.getFont());
            l.setOpaque(true);
            return l;
        }
    });
}
Also used : BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer)

Example 3 with BasicComboBoxRenderer

use of javax.swing.plaf.basic.BasicComboBoxRenderer in project FlatLaf by JFormDesigner.

the class FlatCustomBordersTest method applyCustomComboBoxRendererBorder.

@SuppressWarnings("unchecked")
private void applyCustomComboBoxRendererBorder(JComboBox<String> comboBox, Border border) {
    BasicComboBoxRenderer customRenderer = new BasicComboBoxRenderer();
    customRenderer.setBorder(border);
    comboBox.setRenderer(customRenderer);
}
Also used : BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer)

Example 4 with BasicComboBoxRenderer

use of javax.swing.plaf.basic.BasicComboBoxRenderer in project intellij-tekton by redhat-developer.

the class HubDetailsPageComponent method createMetricsPanel.

private void createMetricsPanel(@NotNull JPanel centerPanel) {
    versionsCmb = new ComboBox();
    BasicComboBoxRenderer versionCmbRenderer = new BasicComboBoxRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value instanceof ResourceVersionData) {
                ResourceVersionData version = (ResourceVersionData) value;
                setText(version.getVersion());
            }
            return this;
        }
    };
    versionsCmb.setRenderer(versionCmbRenderer);
    versionsCmb.addItemListener(e -> {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            ResourceVersionData versionSelected = (ResourceVersionData) e.getItem();
            loadBottomTabs(versionSelected.getDisplayName(), versionSelected.getRawURL());
        }
    });
    myRating = new JLabel("", AllIcons.Plugins.Rating, SwingConstants.CENTER);
    myRating.setOpaque(false);
    myRating.setIconTextGap(2);
    myRating.setForeground(GRAY_COLOR);
    JPanel metricsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    metricsPanel.setBackground(MAIN_BG_COLOR);
    metricsPanel.add(myRating);
    metricsPanel.add(versionsCmb);
    centerPanel.add(metricsPanel);
}
Also used : BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ResourceVersionData(com.redhat.devtools.intellij.tektoncd.hub.model.ResourceVersionData) JComboBox(javax.swing.JComboBox) ComboBox(com.intellij.openapi.ui.ComboBox) JLabel(javax.swing.JLabel) JList(javax.swing.JList)

Example 5 with BasicComboBoxRenderer

use of javax.swing.plaf.basic.BasicComboBoxRenderer in project intellij-tekton by redhat-developer.

the class WorkspacesStep method getBasicComboBoxRenderer.

private ListCellRenderer getBasicComboBoxRenderer() {
    return new BasicComboBoxRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value instanceof Pair) {
                Pair pair = (Pair) value;
                setText(pair.getFirst().toString());
            }
            return this;
        }
    };
}
Also used : BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer) JList(javax.swing.JList) Pair(com.intellij.openapi.util.Pair)

Aggregations

BasicComboBoxRenderer (javax.swing.plaf.basic.BasicComboBoxRenderer)11 JList (javax.swing.JList)6 Component (java.awt.Component)5 JButton (javax.swing.JButton)5 JComboBox (javax.swing.JComboBox)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 FlowLayout (java.awt.FlowLayout)3 JComponent (javax.swing.JComponent)3 PrefComboBox (com.mucommander.ui.dialog.pref.component.PrefComboBox)2 Dimension (java.awt.Dimension)2 Icon (javax.swing.Icon)2 JToggleButton (javax.swing.JToggleButton)2 JToolBar (javax.swing.JToolBar)2 BasicComboBoxEditor (javax.swing.plaf.basic.BasicComboBoxEditor)2 ComboBox (com.intellij.openapi.ui.ComboBox)1 Pair (com.intellij.openapi.util.Pair)1 ProportionalGridPanel (com.mucommander.commons.util.ui.layout.ProportionalGridPanel)1 YBoxPanel (com.mucommander.commons.util.ui.layout.YBoxPanel)1 SpinningDial (com.mucommander.ui.icon.SpinningDial)1