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) {
19              var exploitMethods = (ExploitMode) value;
20              this.setToolTipText(I18nViewUtil.valueByKey(exploitMethods.getKeyTooltip()));
21              this.setText(I18nViewUtil.valueByKey(exploitMethods.getKeyLabel()));
22          }
23          this.setForeground(UIManager.getColor("ComboBox.foreground"));
24          this.setBackground(UIManager.getColor("ComboBox.background"));
25          if (isSelected) {
26              this.setForeground(UIManager.getColor("ComboBox.selectionForeground"));
27              this.setBackground(UIManager.getColor("ComboBox.selectionBackground"));
28          }
29          this.setFont(list.getFont());
30          return this;
31      }
32  }