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);
}
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;
}
});
}
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);
}
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);
}
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;
}
};
}
Aggregations