View Javadoc
1   package com.jsql.view.swing.manager.util;
2   
3   import com.jsql.model.accessible.ExploitMode;
4   import com.jsql.view.swing.util.I18nViewUtil;
5   
6   import javax.swing.*;
7   import java.awt.*;
8   
9   public class ComboBoxMethodRenderer extends JLabel implements ListCellRenderer<Object> {
10      public static final JSeparator SEPARATOR = new JSeparator();
11  
12      public Component getListCellRendererComponent(
13          JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus
14      ) {
15          if (ComboBoxMethodRenderer.SEPARATOR.equals(value)) {
16              return ComboBoxMethodRenderer.SEPARATOR;
17          }
18          if (value instanceof ExploitMode exploitMethods) {
19              this.setToolTipText(I18nViewUtil.valueByKey(exploitMethods.getKeyTooltip()));
20              this.setText(I18nViewUtil.valueByKey(exploitMethods.getKeyLabel()));
21          }
22          this.setForeground(UIManager.getColor("ComboBox.foreground"));
23          this.setBackground(UIManager.getColor("ComboBox.background"));
24          if (isSelected) {
25              this.setForeground(UIManager.getColor("ComboBox.selectionForeground"));
26              this.setBackground(UIManager.getColor("ComboBox.selectionBackground"));
27          }
28          this.setFont(list.getFont());
29          return this;
30      }
31  }