-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSeparatorComboBoxRenderer.java
More file actions
36 lines (30 loc) · 1.12 KB
/
Copy pathSeparatorComboBoxRenderer.java
File metadata and controls
36 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ca.virology.baseByBase.gui.CodeHop;
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import java.awt.*;
// class from http://esus.com/creating-a-jcombobox-with-a-divider-separator-line/
class SeparatorComboBoxRenderer extends BasicComboBoxRenderer implements ListCellRenderer {
public SeparatorComboBoxRenderer() {
super();
}
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setFont(list.getFont());
if (value instanceof Icon) {
setIcon((Icon) value);
}
if (value instanceof JSeparator) {
return (Component) value;
} else {
setText((value == null) ? "" : value.toString());
}
return this;
}
}